我正在使用pureModal
http://leanmodal.finelysliced.com.au需要启动它来打开一个div,但没有.click()方法.基本上我试图这样做..
if(cartItems === 0){ $("#cartEmpty").leanModal(); // #cartEmpty is my div with the message that needs to be initiated. } else { $("#nextStep").leanModal(); // #nextStep is my div is the form }
对这个有什么想法?
解决方法
我通过
source code的笨拙模式,看起来像你不能.您仍然必须有一个链接来触发它.但是,您应该能够像以下未经测试的顶级代码那样做一些事情
添加几个不可见的链接.内联样式是一个坏事,只做内联来简化
<a href="#cartEmpty" id="showCartEmpty" style="display:none" rel="leanModal" name="cartEmpty">empty cart</a> <a href="#nextStep" id="showNextStep" style="display:none" rel="leanModal" name="nextStep">next step</a>
做正常的模式设置
$(function() { $('a[rel*=leanModal]').leanModal(); });
在虚拟的不可见链接上调用点击方法
if(cartItems === 0){ $("#showCartEmpty").click(); // in theory this'll cause the modal to be shown } else { $("#showNextStep").click(); // in theory this'll cause the modal to be shown }
没有这个,源头很小,你应该能够把它摆在你自己的项目中,并修改它可以调用的东西来模拟,而不是启动模态