Ajax 刷新弄乱了 jqModal 功能

发布于 2024-08-03 14:12:30 字数 526 浏览 13 评论 0原文

我正在尝试在 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城°AllureLove 2024-08-10 14:12:30

更新 html 后,您必须再次添加触发器。我遇到了同样的问题。

当您调用 $("#blah").jqmodal... 时,它会在 .jqmodal 类上设置触发器以在模式中加载您的内容。我假设你用ajax加载这些?比如:

$("#someDiv").jqModal({ajax:'@href'});

我对你上面的ajax代码有点困惑,这是在保存你编辑过的项目吗?这通常不是 get,而是 put。不管怎样,看起来你用更新的数据渲染了表格并替换了现有的表格。

$("myDiv").html(结果);

您需要

$("#someDiv").jqmAddTrigger(".jqModal");

在编辑链接上再次添加触发器(假设您首先使用了 .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:

$("#someDiv").jqModal({ajax:'@href'});

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

$("myDiv").html(result);

You need

$("#someDiv").jqmAddTrigger(".jqModal");

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文