locked
LS HTML custom control "list" RRS feed

  • Question

  • I would like to make my own custom control list from an integer.

    Since the integer is a value from 0 to 100, I want the first item to be the integer and the second to be 100 - the integer.

    I'm new to custom controls, is there a way to do this?


    • Edited by Borkith Sunday, March 16, 2014 4:55 PM
    Sunday, March 16, 2014 4:39 PM

Answers

  • I got closer using innerHTML:

        function updateValue() {
            var value = (Math.round(contentItem.screen.CurrentOrder.Strength * contentItem.screen.CurrentOrder.Size * 1000) / 1000 / 100).toFixed(3);
            element.innerHTML = "<div class=\"msls-vauto msls-control-header msls-collapsed\">" +
                "<div class=\"msls-text\"><span class=\"id-element\">Ingredient Details</span></div></div>" +
                "<div class=\"msls-vauto msls-layout-ignore-children\">" +
                "<ul class=\"msls-listview\" data-role=\"listview\" data-inset=\"true\">" +
                "<li tabindex=\"0\" class=\"msls-li msls-style ui-shadow ui-li ui-btn ui-first-child ui-last-child ui-btn-up-a\" data-theme=\"a\" data-icon=\"false\">" +
                "<div class=\"msls-presenter msls-ctl-summary msls-vauto msls-hauto msls-compact-padding msls-leaf msls-presenter-content msls-font-style-normal\">" +
                "<div class=\"msls-text\"><span class=\"id-element\">" +
                value +
                "</span></div></div><div class=\"msls-clear\"></div></li></div></ul></div>";
        };
    
        contentItem.screen.getOrders().then(function () {
            contentItem.dataBind("screen.OrderPosition", function (value) {
                updateValue();
            });
            contentItem.dataBind("screen.OrderCount", function (value) {
                updateValue();
            });
        });

    The problem is with innerHTML. When I navigate away from this screen and try adding an entity in another screen, nothing pops up, I click add again and it asks if I want to save or discard changes (like the popup was there, I just couldn't see it). I tried changing innerHTML to $(element).append and my custom control I want to be a list bcomes text, and the add button on another screen works properly.

    • Marked as answer by Borkith Tuesday, March 18, 2014 4:28 PM
    Monday, March 17, 2014 2:58 PM