I’m using Rails, Devise gem, jQuery validation plugin and Bootstrap.
I can call $(‘#congrats’).show(); when user submit, but it is closing, because user should be automatically redirected after sign up.
Also, I can’t call if page is loaded first time, yes ?
What can I do to call show function at right time ?
MY HTML FORM
<form accept-charset="UTF-8" action="/users" class="sign_up" id="new_user" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="W0u6CgL+sA/n/Zecikl67zLqkIPePQz01Vg0u3bi2nc=" /></div>
<div class="field2">
<label for="user_first_name">First name</label>
<input id="user_first_name" name="user[first_name]" size="30" type="text" /></div>
<div class="field2"><label for="user_last_name">Last name</label>
<input id="user_last_name" name="user[last_name]" size="30" type="text" /></div>
<div class="field2"><label for="user_email">Email</label>
<input id="user_email" name="user[email]" size="30" type="email" value="" /></div>
<div class="field2"><label for="user_password">Password</label>
<input id="user_password" name="user[password]" size="30" type="password" /></div>
<div class="field2"><label for="user_password_confirmation">Re-Type Password</label>
<input id="user_password_confirmation" name="user[password_confirmation]" size="30" type="password" />
</div>
<div class="login_submit">
<input class="btn login" name="commit" type="submit" value="Sign up" />
</div>
</form>
http://guides.rubyonrails.org/action_controller_overview.html#the-flash .. The flash system is in place just to handle such scenarios. The values set in the flash will be persisted only for one redirect. If the user were to refresh the page, the flash value will be automatically unset and the user will not see that message again.
I dont remember erb syntax, but i can write some pseudo code:
in your js code,
We just want erb to print to the page the variable declaration.