-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open on Page Load #34
Comments
I am also looking to do this urgently! |
I have found a way to do this courtesy of Dan F (http://stackoverflow.com/questions/6702887/leanmodal-initiate-without-click?answertab=active#tab-top). Basically you need to create a hidden a href link and call it as a click onLoad. Script:
Hidden Link:
Hope this helps |
(function($){
$.fn.extend({
leanModal:function(options){
var defaults={
top:100,
overlay:0.5,
target:null,
closeButton:null,
auto:false
};
var overlay=$("<div id='lean_overlay'></div>");
$("body").append(overlay);
options=$.extend(defaults,options);
var o=options;
if(o.auto == true) {
var modal_id=o.target;
$("#lean_overlay").click(function(){close_modal(modal_id)});
$(o.closeButton).click(function(e){close_modal(modal_id);e.preventDefault();});
var modal_height=$(modal_id).outerHeight();
var modal_width=$(modal_id).outerWidth();
$("#lean_overlay").css({"display":"block",opacity:0});
$("#lean_overlay").fadeTo(200,o.overlay);
$(modal_id).css({"display":"block","position":"fixed","opacity":0,"z-index":11000,"left":50+"%","margin-left":-(modal_width/2)+"px","top":o.top+"px"});
$(modal_id).fadeTo(200,1);
}
if(o.auto == false) {
return this.each(function(){
$(this).click(function(e){
var modal_id=$(this).attr("href");
$("#lean_overlay").click(function(){close_modal(modal_id)});
$(o.closeButton).click(function(e){close_modal(modal_id);e.preventDefault();});
var modal_height=$(modal_id).outerHeight();
var modal_width=$(modal_id).outerWidth();
$("#lean_overlay").css({"display":"block",opacity:0});
$("#lean_overlay").fadeTo(200,o.overlay);
$(modal_id).css({"display":"block","position":"fixed","opacity":0,"z-index":11000,"left":50+"%","margin-left":-(modal_width/2)+"px","top":o.top+"px"});
$(modal_id).fadeTo(200,1);
e.preventDefault()
})
});
}
function close_modal(modal_id){
$("#lean_overlay").fadeOut(200);$(modal_id).css({"display":"none"})
}
}
})
})(jQuery); and then: $("").leanModal({top:200, target:"#thxforsend", closeButton: ".modal_close", auto:true});
$("a[rel*=leanModal]").leanModal({top:200, closeButton: ".modal_close"}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Love the simple but useful plugin. I need to open the model on Page Load.
Can any one please help?
Thanks in advance.
The text was updated successfully, but these errors were encountered: