I’m using the leanModal http://leanmodal.finelysliced.com.au need to initiate it to open a div but without the .click() method. Basically I’m trying to do this..
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
}
Any ideas on this one?
I took a poke through the source code for leanmodal, looks like you can’t. You’ll still have to have a link to trigger it. But, you should be able to do something like the following untested top-of-my-head code
Add a couple of invisible links in. Inline styles are a Bad Thing, only doing it inline to simplify
Do the normal setup for leanmodal
Call the click method on your dummy invisible link
Failing that, the source is pretty small, you should be able to wrangle it into your own project and modify it to be callable on the thing to modalise, not the thing to launch the modal