Search code examples
javascriptvisual-studio-lightswitchlightswitch-2013

Update custom control in LightSwitch


I am displaying custom text based on a Boolean field from a table in my database.

myapp.BrowseAdverts.AdType_postRender = function (element, contentItem) {
    if (contentItem.data.AdType === true) $(element).append("Advert type = BANNER");
    else $(element).append("Advert type = WOW");
};

After I edit the selected element from a list (or even add a new item), all the fields will update except for this custom control.

How can I setup the "binding" so the custom text will update when a field is modified?


Solution

  • I managed to find the solution myself:

    contentItem.dataBind("value", function (value) {
            if (value === true) {
                $(element).text("BANNER");
            } else {
                $(element).text("WOW");
            }
        });