unrobustive jQuery and rails with ajax and form validation
Posted
by bogumbiker
on Stack Overflow
See other posts from Stack Overflow
or by bogumbiker
Published on 2010-03-11T23:49:20Z
Indexed on
2010/03/12
2:17 UTC
Read the original article
Hit count: 655
Hello, I am looking for a way to call successfully custom function from submitHandler to do proper ajax post.
Here is my custom function:
jQuery.fn.submitWithAjax = function() {
this.submit(function() {
$.post(this.action, $(this).serialize(), null, "script");
return false;
})
return this;
};
Before using validate plugin I had following which worked fine:
$(document).ready(function() { $("#my_form").submitWithAjax(); }
Now I have added the validation part and have no idea how to call my custom submitWithAjax function??
$(document).ready(function() {
$("#my_form").validate({
/*Validations - works perfectly!! */
},
submitHandler: function(form) {
/* $("#my_form").submitWithAjax(); - this works but
introduces recursion */
/* how to call custom subitWithAjax() ????? */
}
});
})
Thanks!
© Stack Overflow or respective owner