我想从现有模式中的链接调用另一个简单模式。
我正在使用 OSX 模式。
我怎样才能做到这一点 ?
SimpleModal only supports one modal open at a time.
Instead of opening a new one, you could get the content you want and replace the existing content with it.
$('#myModal').modal.update();
我认为应该改为$.modal.update();
只有一个模式对话框,因此您不必指定哪一个。
有太多的方法可以做到这一点。我将向您展示其中之一:
a) 假设您正在“simpleModal-ing”一个 id 为“myDisplay”的 div:
<div id='myDisplay' style='.........'></div>
b)您首先在该页面(div)中加载了表单的内容
<div id='myDisplay' style='.........'>
<form ............>
<input this>
<input that>
<submit onClick='updateMyDisplay'>
</form>
</div>
c)在您的页面之间的某处,放置更新脚本:
<script type='text/javascript'> //remember that you could/should have only one of this
function updateMyDisplay() {
//plain html/javascript
document.getElementById('myDisplay').innerHTML="Thank you!";
.. or ..
//jquery
$('#myDisplay').html("Thank you!");
}
</script> //again : could/should have only one of this
...... 最好的方式来实现这样的事情(多个显示与单一模式)是使用 jQuery load():
在主页或脚本页面上,创建一个空的隐藏 div:
<div id='myModal' style='......; overflow:auto; display:none; ' ></div>
然后,用离线(同一页面中的非内容)html页面填充该div
表格......在 myForm.html 文件中 感谢......在thankyou.html 文件中
使用 jquery(对我来说最简单的事情):
.......
$('#myModal').load('myForm.html');
$('#myModal').height('650px');
$('#myModal').modal();
.......
// on completion of the form:
$('#myModal').load('thankyou.html');
$('#myModal').modal.update(); // (Eric Martin, himself, sent me this tip through Twitter)
.......
无论如何,如果您是“代码借用者”......像我一样,您可能无法理解上述内容,但无论如何,我希望我对您有所帮助。