Reputation: 117
thanks for looking.
I'm having an issue i cant seem to get the submit function workin.
load login form if needed.
login_box_comment = function(){
$("body").append('<div id="login_form_modal" style="display:none">'+
'<div id="status" align="left">'+
'<center><h1><img src="/ext/login/img/key.png" align="absmiddle"> LOGIN</h1>'+
'<div id="login_response"><!-- spanner --></div> </center>'+
'<form id="login" action="javascript:alert(\"success!\");">'+
'<input type="hidden" name="action" value="user_login">'+
'<input type="hidden" name="module" value="login">'+
'<label>Username</label><input type="text" name="user"><br />'+
'<label>Password</label><input type="password" name="password"><br />'+
'<input type="checkbox" name="autologin" id="autologin" value="1">Log me on automatically each visit<br />'+
'<input type="checkbox" name="viewonline" id="viewonline" value="0">Hide my online status this session<br />'+
'<label><a href="/forum/ucp.php?mode=register">Register</a> | </label><input value="Login" name="Login" id="submit" class="big" type="submit" />'+
'<div id="ajax_loading">'+
'<img align="absmiddle" src="/ext/login/img/spinner.gif"> Processing...'+
'</div>'+
'</form>'+
'</div>'+
'</div>');
$('#login_form_modal').modal();
}
and ths submit function
$("#status > form").submit(function(){
alert('working');
}):
Upvotes: 1
Views: 962
Reputation: 1038710
You need to attach the submit
handler only after the form has been appended to the DOM. So, you need to first make sure the login_box_comment
function is called and only then attach the event because if the form is not present in the DOM the jQuery won't do anything:
login_box_comment();
$('#status > form').submit(function() {
alert('working');
});
or simply attach the submit
handler inside the login_box_comment
function:
login_box_comment = function() {
$('body').append('.......');
$('#status > form').submit(function() {
alert('working');
});
$('#login_form_modal').modal();
};
Upvotes: 1