This is a migrated thread and some comments may be shown as answers.

Problem with Add in MVVM with Icenium

1 Answer 50 Views
ListView (Mobile)
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 01 Jul 2013, 08:12 PM
Started with the Icenium / Everlive / Kendo MVVM example. My add model for the class YFKey (name, description, status) is as follows:

    window.addYFKeyViewModel = (function () {
        var $newName, $newDescription, $newStatus;
        var validator;
        var init = function () {
            validator = $('#enterStatus').kendoValidator().data("kendoValidator");
            $newStatus = $("#newStatus");
            $newName = $('#newName');
            $newDescription = $('#newDescription');
        };
        var show = function () {
            $newStatus.val('');
            $newName.val('');
            $newDescription.val('');
            validator.hideMessages();
        };
        var saveYFKey = function () {
            alert("In saveYFKey");
            if (validator.validate()) {
                var items = YFKeysModel.YFKeys;
                var item = items.add();
                item.Name = $newName.val();
                item.Description = $newDescription.val();
                item.Status = 0;
                item.IsSystem = false;
                item.UserId = usersModel.currentUser.get('data').Id;
                items.one('sync', function () {
                    window.mobileApp.navigate('#:back');
                });
                items.sync();
                items.refresh();
            }
        };
        return {init: init, show: show, me: usersModel.currentUser, saveYFKey: saveYFKey};
    }());

This is accessed by an "Add" button from the listview of YFKeys (working fine) modeled exactly after the activities class within the example. Problem is this: AFTER I do an Add to the class YFKey, give new data, and hit the Save button, Everlive database IS properly updated, but the new item is in my listview with blank values, i.e., no name, and no description.

Not sure - probably an asynch problem? Not clear what the "one" function in your example does...

Any ideas?
Thanks.
CW

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 03 Jul 2013, 02:25 PM
Hi Chris,

I am not sure what goes on in your case. It is unlikely that the problem is caused by the async call, though. Can you try reproducing the problem in an isolated case? You may use the jsbin service.

Regards,
Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ListView (Mobile)
Asked by
Chris
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or