javascript - How to initial a jquery mobile flipswitch in ajax callback -


requirement:
when click button ,send ajax request ,get result , create list,in list ,i wan't use flip-switch widget
know ,the flip-switch widget won't initialed in callback automatically,but how initial myself?
what tried?
tried fresh method,but error :"fresh can't used before initial"
tried trigger create event ,but doesn't work.
appreciate help!

template:<li class="clearfix">                     <span class="keyword-name">{{name}}</span>                     <div class="keyword-monitor">                         <select data-role="slider" data-mini="true" class="monitor" data-ruleid="{{rule_id}}" data-isoff="{{is_off}}" data-type="{{type}}">                             <option value="0" >取消</option>                                  <option value="1" >监测</option>                         </select>                     </div>     </li> 
  function initdefaulttab(index){ $.ajax({   url:"/usercenter/defaultwords/"+index,   method: "post",   datatype: "json"       }).done(function(data){   var html="";   var source = $("#default-keyword-template").text();   var template = handlebars.compile(source);   for(var i=0;i<data.length;i++){     var $temp=$(template({       name: data[i].name,       rule_id: data[i].rule_id,       is_off:data[i].is_off,       type:data[i].type     }));     if(data[i].is_off===1){       $temp.find("option").eq(0).attr("selected",true)     }else{       $temp.find("option").eq(1).attr("selected",true)     }             html+="<li class='clearfix'>"+$temp.html()+"</li>";   }   var $html = $(html);        $("#defaultword-"+index).find("ul").append($html);   $("#defaultword-"+index).find(".monitor").flipswitch({enhanced:true}); });}   


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -