Ajax 刷新弄乱了 jqModal 功能
我正在尝试在 .net/mvc 应用程序中使用 jqModal 来执行简单的 jquery 模式弹出窗口。我有一个表格,其中列出了记录,并有一个“编辑”按钮来弹出一个模式对话框来进行编辑。当我提交时,我隐藏模式弹出窗口并使用 .ajax() 方法刷新下面列出的表格。
但是,现在当我单击“编辑”页面时,jqModal 不会触发,而是直接进入我的编辑页面(而不是模式弹出窗口)。
我尝试在 ajax 回调后重新注入 jqModal 脚本,但这也不起作用。任何帮助表示赞赏!
$.ajax(
{
type: "GET",
url: "HomePage/ViewTimelineFeatures",
dataType: "html",
success: function(result) {
$("myDiv").html(result);
// Now re-initialize jqModals here doesn't work...
}
});
I am trying to use jqModal in my .net/mvc app to do simple jquery modal popups. I have a table where I list out records and have an "edit" button to popup a modal dialog to do the edits. When I submit, I hide the modal popup and refresh the table listing below using the .ajax() method.
However, now when I click on the "edit" page, jqModal isn't firing and instead it just goes to my edit page directly (rather than the modal popup).
I've tried to re-inject the jqModal scripts after the ajax callback but that doesn't work either. Any help appreciated!!!
$.ajax(
{
type: "GET",
url: "HomePage/ViewTimelineFeatures",
dataType: "html",
success: function(result) {
$("myDiv").html(result);
// Now re-initialize jqModals here doesn't work...
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新 html 后,您必须再次添加触发器。我遇到了同样的问题。
当您调用 $("#blah").jqmodal... 时,它会在 .jqmodal 类上设置触发器以在模式中加载您的内容。我假设你用ajax加载这些?比如:
我对你上面的ajax代码有点困惑,这是在保存你编辑过的项目吗?这通常不是 get,而是 put。不管怎样,看起来你用更新的数据渲染了表格并替换了现有的表格。
后
您需要
在编辑链接上再次添加触发器(假设您首先使用了 .jqModal),如果您想粘贴一些 html/ajax 代码,我可以验证这一点。
You have to add in the triggers again after updating the html. I had this exact same problem.
WHen you call $("#blah").jqmodal... it sets up the trigger on the .jqmodal class to load your content in the modal. I'm assuming you're loading these with ajax? So something like:
I'm a bit confused by your above ajax code, is this doing a save of the item you've edited? This wouldn't normally be a get, but a put. Anyway, it looks like you render out the table with the updated data and replace the existing one.
After
You need
To add the triggers again on your edit links (assuming you used .jqModal in the first place) If you want to paste in some html/ajax code I can verify this.