在动态加载的html上使用jqgrid
use jqgrid on dynamically loaded html
我有一个模式对话框,它通过AJAX调用加载其主体。在加载的正文中,我有使用jqGrid
的HTML标记。
$.get('@Url.Action("ListPartial")',null, function(data, txtStatus, jqXHR) {
customModal('Modal header', data);
createListGrig("");
});
customModal
方法
function customModal(title, body) {
var modal = $('#modalDialog');
modal.find('h6.modal-title').html(title);
modal.find('#modalBody').html(body);
modal.modal();
}
createListGrig
方法将jqGrid
应用于加载的html。
问题是,当我的模态出现时,网格的宽度为0。但是,当我添加setTimeout 1秒时,它会像预期的那样出现。
setTimeout(function (){createListGrig("")}, 1000);
请帮我计算出应用jqGrid
的确切时间
正如@A.Wolff在他的评论中提到的那样,正确的时刻是调用模态的shown
方法。我更新了我的代码,使其正确工作:
$.get('@Url.Action("ListPartial")',null, function(data, txtStatus, jqXHR) {
customModal('Copy Address from Partner', data, function() {
createListGrig("");
});
});
和customModal
方法
function customModal(title, body, callBack) {
var modal = $('#modalDialog');
modal.find('h6.modal-title').html(title);
modal.find('#modalBody').html(body);
modal.on('shown.bs.modal', function (e) {
if (callBack) callBack();
});
modal.modal();
}
相关文章:
- 可以't让我的if语句处理js中的html表单输入
- 如何设置html元素填充的动画
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何将HTML id分配给元素,以及如何将JavaScript应用于元素
- 如何编写HTML输入的JS内联
- Dojo不解析自定义小部件的模板html中的小部件声明性
- 使用javascript将动态表从一个html页面打印到另一个html页
- 通过javascript重定向html传递php变量
- 如何使Javascript动态html表及其上的事件
- 在chrome.tabs.onCreated之后加载HTML页面
- 如何在vs2002中调试html页面
- 如何使用javascript或html下载PDF格式的填写表单
- 使用getCell jqgrid获取html值
- 在动态加载的html上使用jqgrid
- 无法从jqgrid编辑表单中打开对话框,除非将html直接输入到对话框函数中
- jqgrid - 为什么在jquery.ajax(type:html)之后,jqgrid重新加载事件不起作用
- jqgrid asp.net-Javascript字符串HTML合成
- 使用jqgrid将html表格转换为pdf
- 将 jQgrid rowid 从 iFrame 传递到主.html的对话框
- jqGrid到html表的转换