javascript - Knockout containerless 'with' binding not working -


this containerless with binding doesn't set bindingcontext expect; it's still set containing parent of ladder.

<!-- ko with:ladder --> <table>     //context here $root object, not $root.ladder     //some foreach binding here </table>  <a  href="#" data-bind="click: addpages">add 4 pages</a> <!-- /ko --> 

this containerful method works fine though.

<table class="ladder-table" data-bind="with:ladder">     //the context correctly set ladder in instance     //some foreach binding here </table> <br /> <a  href="#" data-bind="click: ladder.addpages">add 4 pages</a> 

anyone know what's that? google didn't give results.

the problem durandal, not knockout, answer explains: containerless statements of knockoutjs not working in hottowel spa?

in short, durandal allows 1 root element per view.

goodview.html

<div>     <--ko foreach:stuff-->       //stuff     <--/ko--> </div> 

badview.html

<div>    <stuff/> </div> <--ko foreach:stuff-->  //these elements stripped out   //stuff <--/ko--> 

thanks @nemesv


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -