none
[HTML5] Data binding on a newly created item in a list RRS feed

  • Question

  • Hi all, 

    How can I databind on a newly created item in a list?

    I have a browse screen and a Add/Edit screen. The browse screen has databinding on the list items:

    myapp.BrowseEmployees.RowTemplate_postRender = function (element, contentItem) {
        function updateEmployee(newValue) {
            $(element).text(newValue.getFullName());
        }
        contentItem.dataBind("value", updateEmployee);
    };

    When on the browse screen and pressing the Add button, the Add/Edit screen shows up and the databind function is triggered. But after saving the new item, the databinding isn't triggered again. 

    What's the clue?
    Michiel

    Sunday, April 21, 2013 8:06 AM

Answers

  • Hi,

    You're setting up a data bind to the content item's "value", which is the Entity Object. When you add a new entity, the "value" property does change (from undefined to a new Entity Object). When you save the new item, the "value" property does not change because it's still the same old entity object.

    I think data bind to "value.FullName" is what you need.

    Best regards,
    Huy Nguyen

    • Marked as answer by Chielus Monday, April 29, 2013 6:15 PM
    Monday, April 22, 2013 5:44 PM

All replies

  • Hi,

    You're setting up a data bind to the content item's "value", which is the Entity Object. When you add a new entity, the "value" property does change (from undefined to a new Entity Object). When you save the new item, the "value" property does not change because it's still the same old entity object.

    I think data bind to "value.FullName" is what you need.

    Best regards,
    Huy Nguyen

    • Marked as answer by Chielus Monday, April 29, 2013 6:15 PM
    Monday, April 22, 2013 5:44 PM
  • Thanks Huy, thought I've tried this, but it does work now!
    Monday, April 29, 2013 6:17 PM