Wednesday, May 16, 2012

knockout checkboxlist with dynamic data

sup guys, my english is not good.. but i'll try my best



I'm new with knockout, I'm really impressed with this tool.
I'm using this framework on my new page in my MVC 3 application. But i just faced a problem on how to mark my checkboxlist with data from the database.



<div data-bind="foreach: listPeople">
<div>
<label>
<input type="checkbox" data-bind="attr: { value: id_person}, checked: $parent.checkedPeople " />
<span data-bind="text: name_person"></span>
</label>
</div>
</div>


as u guys can see, im using the checked tag to "hold" the id_person information to save im my database.



listPeople is an observableArray with my people.
and checkedPeople is an observableArray with those chosed people.



while inserting its working like a piece of cake.
the problem is when im tryin to "edit". When i try to previous populate "checkedPeople".



isnt knockout supposed to recognize it ?





No comments:

Post a Comment