jquery - .html property updates once once -


i have following divs

<div id="daily" style="display:none">    <p class="scheduledata">every <input type="text" data-bind="value:everynperiods"/> days       </div>  <div id="weekly" style="display:none">      <p class="scheduledata">recur every <input type="text" data-bind="value:everynperiods" style="width:20px; "/>week(s) on: </p><br/> </div> 

i have drop down contains daily , weekly options. on dropdown change must able load contents of other div. here code this:

$("#dropdown").change(function () {     var selected = $("#dropdown").val();     if (selected == "daily") {         $("#divtobeloaded").html("");         //$("#divtobeloaded").html($("#daily").html());         $("#divtobeloaded").html($("#daily").contents());     } else if (selected == "weekly") {         $("#divtobeloaded").html("");         $("#divtobeloaded").html($("#weekly").contents());  }); 

the problem divtobeloaded gets updated once each dropdown option (for example, first time change weekly, div gets loaded contents of weekly div. if change daily, gets loaded. when switch weekly, div not load). if use .html instead of .contents works fine. loosing knockout bindings if use .html property creates new nodes.

close else loop wth '}'

var selected = $("#dropdown option:selected").val();    //try if (selected == "daily") {     $("#divtobeloaded").html("");     //$("#divtobeloaded").html($("#daily").html());     $("#divtobeloaded").html($("#daily").contents()); } else if (selected == "weekly") {     $("#divtobeloaded").html("");     $("#divtobeloaded").html($("#weekly").contents()); }  //end of else if 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -