SimpleModal和mvc,在IFrame中打开时调用页面两次

发布于 2024-09-13 17:58:50 字数 292 浏览 1 评论 0原文

我正在使用 asp.net mvc 2 和 Simplemodal 与 iframe

它工作得很好,但在 iframe 中打开时我的控制器被调用两次 当我直接调用页面时,控制器仅被调用一次(

 $.modal('<iframe id="frmDetails" src="' + src + '" >', { containerCss: { height: "90%", width: "90%"} });

是否有我缺少的选项),这是一个非常简单的调用。

谢谢

i'm using asp.net mvc 2 and Simplemodal with iframe

it works great but my controller is being called twice when opening in iframe
when i call the page directly, the controller is called only once

 $.modal('<iframe id="frmDetails" src="' + src + '" >', { containerCss: { height: "90%", width: "90%"} });

is there an option that i'm missing, it's a very simple call.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

灰色世界里的红玫瑰 2024-09-20 17:58:50

检查以确保您没有多次包含 jquery js 文件或其他 javascript 文件。

Check to make sure that you don't have the jquery js file or other javascript files included more than once.

不再见 2024-09-20 17:58:50

我有同样的问题。当首页(包含 iframe)和 iframe 中加载的页面都加载 jquery 时,它会加载 iframe 两次。如果您从首页删除 jquery,它只会加载一次。

我目前没有解决方法。

I have the same problem. When the top page (which contains the iframe) and the page loaded in the iframe both load jquery, it does load the iframe twice. If you remove the jquery from the top page, it only loads once.

A workaround I don't have at the moment.

青春如此纠结 2024-09-20 17:58:50

尝试

$.modal('<iframe id="frmDetails" src="' + src + '" ></iframe>', {
    containerCss: { height: "90%", width: "90%"},
    appendTo: 'form'
});

Try

$.modal('<iframe id="frmDetails" src="' + src + '" ></iframe>', {
    containerCss: { height: "90%", width: "90%"},
    appendTo: 'form'
});
笑脸一如从前 2024-09-20 17:58:50

我建议,在您的情况下,当您调用 $.model 时,它会创建一些(例如 div)隐藏元素,其中存储模式窗口的 html。此时 iframe 正在隐藏元素中第一次加载。然后它向用户显示 - 使用新的 iframe 创建新的非隐藏元素,这就是为什么你会收到第二次调用。可能您应该仅在向用户显示时定义 iframe 的 src 。所以如果我是对的,你将有 2 个 iframe。为未隐藏的 iframe 选择正确的选择器。

I suggest, that in your case, when you call $.model it creates some (for example div) hidden element where stored html of your modal window. In this point iframe is loading 1st time in hidden element. Then it shows to user - creates new not hidden element with new iframe, that's why u'll get second call. Possible you should define src of iframe only when it's showing to user. So if i'm right you will have 2 iframes. Choose right selector for your iframe that is not hidden.

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