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
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