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.  

posted on 2018-09-07 10:44  雪原日暮  阅读(2983)  评论(0编辑  收藏  举报