Reputation: 1689
I've login form as shown below,
<a href="#" id="loginLink">click Here to Log in</a>
<div class="formDiv" id="formDiv">
<form name="loginForm" id="loginForm" action="#">
<label>Email</label><input type="text" name="email" id="email"><br/>
<label>Passw</label><input type="password" name="pwd" id="pwd"><br/>
<input type="submit" value="Log in" id="loginbtn" name="loginbtn">
</form>
</div>
I want to submit this form data using Ajax
,for that when user clicks on #loginbtn
I'm doing Ajax related stuff,but the trouble is click
event not firing when clicks on #loginbtn
,here is jsfiddle .
Upvotes: 1
Views: 5842
Reputation: 44824
or you could create buttons within the dialog definition as in
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Login": function() {
alert('test');
$( this ).dialog( "close" );
}
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
Upvotes: 0
Reputation: 1338
Try to bind the click event like this:
$(document).on("click","#loginbtn",function(e){
// do stuff
})
Upvotes: 2
Reputation: 3778
Since the div which holds the dialog is dynamically added, you cannot bind click event to it. Bind it instead to some parent which is fixed like document
.
I have edited the fiddle and it works: http://jsfiddle.net/WNMfA/2/
Upvotes: 4