jquery - Knockout: DOM not updated until resize -


i have div data bound using knockout foreach syntax.

<div id="mydiv" data-bind="foreach: { data: mydata }, mycustombinding: { param: paramname }">      <a id="mylink" class="mylink" data-bind="text: label"></a> </div> 

mydata observablearray holds data. have knockout subscribe on mydata follows:

mydata.subscribe(function () { if (mydata().length > 0) {      resizediv();  } }); 

in resizediv() function trying remove few links div , move different hidden div if size of controls combined greater div width. problem controls width not available @ moment of time. control width refreshed in dom after resizing browser. have added window resize event calls same resizediv() method.

$(window).on('resize', function () {    resizediv(); }); 

not sure if able convey issue/concern. please let me know if need further information.

update: here fiddle http://jsfiddle.net/2m3jk/7/ . binding handler not firing in fiddle. in application binding handler firing , menu items moving 1 div if resize window. not on page load.

i don't recommend use dom manipulation plain javascript if it's competing knockout in rendering process. maybe can use afterrender binding call resize function: http://knockoutjs.com/documentation/template-binding.html#note-4-using-afterrender-afteradd-and-beforeremove


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -