javascript - Knockout.js: adding elements to observable-array -


i have problem loading element items observable-array - event.

viewmodel = (function () {     var          items = ko.observablearray([]),          removeitems = function (element) {             items.remove(element);         },         saveall = function () {             return ko.tojs(items);         },         additem = function (element) {             items.push(element);             return false;  // no page-reload after button-klick         };      return {         items: items,         // call additem dummy object (for testing)         clicksave: additem(new customer(1, "tfsd", "tfsd"))     }; })(); 

(fiddle)

why additem function called, without clicking button? because of () @ end of function?

    additem = function (element) {         items.push(element);         return false;  // no page-reload after button-click     }; 

what can make event only? or problem somewhere else?

use

return {     items: items,     clicksave: additem }; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -