Reputation: 53
So I have a javascript function that shows the register form after the onclick but it doesn't refresh because it is on the same page. It just loads another form in. But when I have the Reset Password page and I want a button that goes directly to the register form instead of the standard login form and that you have to click manually on the register button.
How can I fix that after the click on the a href the page refreshes and that it will use the javascript code so it will show the register form instead of the login form.
$('.register-pass-reset').click(function(){
// Switches the forms
('.form').animate({
height: "toggle",
'padding-top': 'toggle',
'padding-bottom': 'toggle',
opacity: "toggle"
}, "slow");
$('.help-block').remove();
$('.toggle').html($('.toggle').html() == 'Register' ? 'Login' : 'Register');
});
The a href:
<a class="register-pass-reset" href="{{ url('/login') }}">
Upvotes: 1
Views: 4889
Reputation: 301
You'll want to link to url('/login#register')
, then detect the hash in the JS when the page loads:
window.onload = function(){
if(window.location.hash && window.location.hash == "#register") {
//Change Login To Register Form
}
}
Upvotes: 1
Reputation: 1995
For detail about Web Storage Click here
You should use HTML WEB STORAGE
to keep track of page. Like if reset_password
button is pressed then store a key with yourself in storage
.
Then in the other page access that key and show the register form on the basis of its value
and then reset the key to null in storage for future usage.
Here is how to use HTML web storage.
When reset_password
button is pressed add the below code in its click event.
localStorage.setItem("register", "true");
// where register is the key and its value is true
In another page access this key
in its DOM ready function like
$(function(){
if(localStorage.getItem("register") === "true") {
// show your register form and reset the storage.
localStorage.setItem("register","");
} else {
}
});
Upvotes: 1