简单的模态问题 - 多个、消失的内容
我是一名 jQuery 新手,通过在我的脚本中执行此操作,我已经操纵了简单模态,以允许我在页面上拥有多个模态:
$('input.basic, a.basic').click(function ( e) { e.preventDefault(); $(this).next('.basicModalContent').modal(); });
这是我的 HTML:
<a class="basic linkHeading" href="#">Link Heading</a>
<div class="basicModalContent" style="display: none;">
<h1>This Resource Requires Login</h1>
<a href="#" class="simplemodal-close" title="Close">Cancel</a></p>
</div><!--basicModal-->
我遇到的问题是第一次点击后一切正常。关闭。第二次单击启动模式,但所有内容都从框中消失。
请参阅此链接以了解正在发生的错误: http://blanksky.com/test/ebenefits21/modal .html
I'm a jQuery newbie and have rigged Simple Modal to allow me to have more than one modal on a page by doing this in my script:
$('input.basic, a.basic').click(function (e) {
e.preventDefault();
$(this).next('.basicModalContent').modal();
});
here's my HTML:
<a class="basic linkHeading" href="#">Link Heading</a>
<div class="basicModalContent" style="display: none;">
<h1>This Resource Requires Login</h1>
<a href="#" class="simplemodal-close" title="Close">Cancel</a></p>
</div><!--basicModal-->
The issue I'm running into is everything works fine on first click & close. The second click launches the modal, but all the content is gone from inside the box.
see this link for the bug in action: http://blanksky.com/test/ebenefits21/modal.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议类似:
链接:
隐藏内容(通过CSS或内联样式)
JavaScript:
类似的东西应该可以解决问题。
I would suggest something like:
Links:
Hidden content (via CSS or inline style)
JavaScript:
Something like that should do the trick.
当你隐藏对话框时,jQuery改变了div在DOM中的位置,然后想用“
$(this).next(...)
”来定位它,你不能这样做。您应该有一些 ID 或参考资料,以便以其他方式查找。编辑:
好吧,你让我的想法有点回响。我希望我正在经历的代码有用。我没有经过测试:
When you hide the dialog, jQuery changes the position of the div in the DOM, then wanting to locate it with "
$(this).next(...)
", you can not do. You should have some ID or a reference to locate otherwise.EDIT:
Well, you have me thinking a little echo. I hope it is useful the code that I'm going through. I'm not tested:
需要较少标记的解决方案是使用单个模式“窗口”。请参见以下示例:
A solution that requires less markup is to use a single modal "window." See the following example: