easyui 動態添加組件 要重新渲染


做項目時動態添加組件是常有的事,easyui動態添加組件時樣式會失效,這是因為這個組件沒有經過

easyui的解析器解析, 比如:

  1.  

    <pre name="code" class="javascript">var newElement = '<a id="btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">easyui</a>';
    $(newElement).appendTo("#container");

  2.  

    var newElement = '<a id="btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">easyui</a>';
    $(newElement).appendTo("#container");
    $.parser.parse(newElement);

這個時間添加的只是正常的a標簽,需要用easyui的解析器解析之后才是easyui的組件

 

 

https://blog.csdn.net/fkbush/article/details/50174823

 

  1.  
    var newElement = '<a id="btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">easyui</a>';
  2.  
    $(newElement).appendTo( "#container");
  3.  
    $.parser.parse(newElement);
  4.  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM