使用JqueryEasyUI的时候,我们从后台传过来easyui的元素无法正常显示。
在开发的时候我们会遇到这样一个问题。
//点击页面 添加事件
//得到选课组的信息
- function getClozeGroupInfo() {
- var clozegroup_id = $('#clozegroup').val();
- $.post('/index.php/ajax/getClozeExperiment',{id: clozegroup_id},function(data){
- $('#experimentList').html(data);
- });
- }
我们会使用$.post来获取我们需要的内容。
但是如果我获取的页面中存在Jquery easyUI的东西,那么获取过来的元素是无法被解析的。
比如
- <input id="room2" url="/index.php/ajax/getRoomList" valueField="id" textField="name" class="easyui-combobox" multiple="true" name="room" style="width:100px" required="true">
在获取到的这个input里面,有class="easyui-combobox"。
那么直接获取过来是无法使用的。
这种情况下,我们需要对获取过来的html元素进行重绘。
- function getClozeGroupInfo() {
- var clozegroup_id = $('#clozegroup').val();
- $.post('/index.php/ajax/getClozeExperiment',{id: clozegroup_id},function(data){
- $('#experimentList').html(data);
- $.parser.parse($('#experimentList'));
- });
- }
这样,页面中的jquery元素就能够正常了。
转载于:https://blog.51cto.com/leexiaobo/928726