Collections Example - deleting row - question

32 views
Skip to first unread message

Meike Rudolph

unread,
Dec 4, 2013, 7:08:16 AM12/4/13
to knock...@googlegroups.com
Hello

I am doing the tutorial "Working with Lists and Collections". 

1.) What does javascript internally "do", that the whole row is deleted?
     I think it is because on using "$root". So where exactly is $root pointing to? 
     1) Does $root.removeSeat point to an seat/element in the array?
     2) Removes the item in the array
     3) And because it is an observable the view of the array is updated and the row therewith deleted?

    <tbody data-bind="foreach: seats">tr>
<td><input data-bind="value: name" /></td>
<td><select data-bind="options: $root.availableMeals, value: meal, optionsText: 'mealName'"></select></td>
<td data-bind="text: formattedPrice"></td>
<td><a href="#" data-bind="click: $root.removeSeat">Remove</a></td>
</tr>  
...

In ViewModel:
self.removeSeat = function(seat) { self.seats.remove(seat) }

Thanks, Meru 

Patrick Steele

unread,
Dec 5, 2013, 7:37:58 AM12/5/13
to knock...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Meike Rudolph

unread,
Dec 5, 2013, 4:37:01 PM12/5/13
to knock...@googlegroups.com
Thanks for the answer! I think I am a bit wiser;).
Reply all
Reply to author
Forward
0 new messages