如何以编程方式调用 simplemodal osx 插件?
我已经实现了 JQuery 的 simplemodal 插件。顺便说一句,非常好!我遇到的问题是,我有一个从数据库生成的链接列表,当我单击其中一个时,我会进行“加载”调用并将结果添加到我的 osx-modal-content div 中。加载完成后如何调用 osx 插件?如果我将 class=osx 添加到我的 a href,模式会在内容进入 div 之前打开。
我的加载 html 的功能:
function loadContent(id) {
$("#osx-modal-dialog").load("Item.cfm?ID="+id+"");
// call OSX here????
$('#osx-modal-dialog').modal();
}
我的 DIV:
<div id="osx-modal-dialog">
<div id="osx-modal-content">
<div id="osx-modal-title">Title</div>
<div id="osx-modal-data">
<h2>Summary</h2>
<p>Description</p>
<p><button class="simplemodal-close">Close</button> <span>(or press ESC or click the overlay)</span></p>
</div>
</div>
</div>
当前 osx 插件正在寻找输入或单击事件。我不确定如何在负载后编写“点击”事件脚本。或者也许有更好的方法来调用插件。
包括:
I've implemented the simplemodal plugin for JQuery. Very nice btw! Where I'm having an issue, is I have a list of links that are generated from a database, when I click one, I make a "load" call and add the results to my osx-modal-content div. How do I call the osx plugin after my load completes? If I add class=osx to my a href, the modal opens before the content get into the div.
My Function to load html:
function loadContent(id) {
$("#osx-modal-dialog").load("Item.cfm?ID="+id+"");
// call OSX here????
$('#osx-modal-dialog').modal();
}
My DIV:
<div id="osx-modal-dialog">
<div id="osx-modal-content">
<div id="osx-modal-title">Title</div>
<div id="osx-modal-data">
<h2>Summary</h2>
<p>Description</p>
<p><button class="simplemodal-close">Close</button> <span>(or press ESC or click the overlay)</span></p>
</div>
</div>
</div>
Currently the osx plugin is looking for input or a click event. I'm not sure how to script a 'click' event ofter my load. Or maybe there is a better way to call the plugin.
Includes:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我要做的:
修改 OSX 内容(我删除了大部分内容并添加了占位符):
您的 loadContent 函数
:
我还没有测试过,但我很确定这应该可以解决问题。
-埃里克
Here's what I would do:
Modify the OSX content (I removed most of the content and added a placeholder):
Your loadContent function:
I haven't tested it, but I'm pretty sure this should do the trick.
-Eric
load 方法有一个回调参数,您可以在其中提供一个在加载完成时执行的函数。使用此回调来触发对话框。
更新:我已更新此内容以展示如何在 load() 的回调中添加点击处理程序,但我不知道您要处理什么事件,也不知道该事件在哪个元素上触发。我假设您希望在单击“show-info”类的按钮时显示对话框。
The load method has a callback parameter where you can supply a function that will be executed when the load has completed. Use this callback to do trigger the dialog.
Update: I've updated this to show how to add a click handler in the callback of load(), but I don't know what event you want to handle nor what element the event is triggered on. I'll assume that you want to show the dialog when you click a button with class "show-info".