Search code examples
knockout.jsknockout-mapping-pluginknockout-sortable

KnockoutJS mapping adding new item does not work


I am working on a list which has tasks and subtasks (nested list).. I am implementing KO Sortable in it. Sortable just works fine but when I try to add new task, it does not simply work..

I am using mapping with the following code :

    self.Tasks = ko.mapping.fromJS(dummyData);

Here is the JSfiddle I am working on :

http://jsfiddle.net/rahulrulez/z9fJV/7/

How can I solve the issue?

I also want to add subtasks directly, is there any better way to do it?

One more thing I will be doing in advance. I need to track the priority order in future

Please help me with it :-) Thanks a ton in advance..


Solution

  • 1) In one place, you have "observable" spelled as "observble".

    2) In ko.applyBindings, you need to instantiate your VM with new.

    3) Your click bindings for getSelectedTask need to be qualified with $root because it's not a method of the individual task models.