I have this Login/Signup link on which when user clicks,it pops up a login window.
Now when a user has to login he can simply login through this pop window.
This is the code for the login/signup link
<a id="modal_trigger" href="#modal" style="margin-top:6px; margin-right:14px">Login|Signup</a>
Given is the Jquery for the pop up window
$("#modal_trigger").leanModal({top : 50, overlay : 0.6, closeButton: ".modal_close" });
$(function(){
// Calling Login Form
$("#login_form").click(function(){
$(".social_login").hide();
$(".user_login").show();
return false;
});
// Calling Register Form
$("#register_form").click(function(){
$(".social_login").hide();
$(".user_register").show();
$(".header_title").text('Register');
return false;
});
// Going back to Social Forms
$(".back_btn").click(function(){
$(".user_login").hide();
$(".user_register").hide();
$(".social_login").show();
$(".header_title").text('Login');
return false;
});
})
Note : i have tried this document.getElementById('modal_trigger').click(); and possibly this might be a duplication of this question How do I programmatically click a link with javascript? but i don't seem to get my answer.
Question : Pop up window comes only comes up when user clicks the 'Login/Signup' hyperlink.How do i make this pop up to come programmingly ?
Update:
$( document ).ready(function() {
$("#modal_trigger")[0].click();
});
$( document ).ready(function() {
$(function() {
$("#modal_trigger").leanModal({top: 50, overlay: 0.6, closeButton: ".modal_close"});
$(function () {
// Calling Login Form
$("#login_form").click(function () {
$(".social_login").hide();
$(".user_login").show();
return false;
});
// Calling Register Form
$("#register_form").click(function () {
$(".social_login").hide();
$(".user_register").show();
$(".header_title").text('Register');
return false;
});
// Going back to Social Forms
$(".back_btn").click(function () {
$(".user_login").hide();
$(".user_register").hide();
$(".social_login").show();
$(".header_title").text('Login');
return false;
});
})
});
});
Tried This one as well.Didn't work.
CODEPEN : http://codepen.io/monkeytempal/pen/VvKLMe Here is the working code in codepen.