'Jquery migrate some code form .live() to .on()
How to migrated this code?
$("#contact-form").find('textarea,input').jqBootstrapValidation({
preventSubmit: true,
submitError: function ($form, event, errors) {
},
submitSuccess: function ($form, event) {
event.preventDefault();
if (validate()) {
sendFormData();
}
else {
messageSendError("Warning! Please validate captcha before send new message.");
}
return false;
},
filter: function () {
return $(this).is(":visible");
},
});
I try this one. No luck. What am I doing wrong?
$(document).on('find', '#contact-form', 'textarea,input', function () {
$(this).jqBootstrapValidation({
preventSubmit: true,
submitError: function ($form, event, errors) {
},
submitSuccess: function ($form, event) {
event.preventDefault();
if (validate()) {
// sendFormData();
}
else {
// messageSendError("Warning!.");
}
return false;
},
filter: function () {
return $(this).is(":visible");
},
});
});
The 3th parametar which I pass is 'textarea,input'? Is this a wrong? How to converted? The live method was easy. This .on() is difficult is difficult and more complicated .
Some info
$( selector ).live( events, data, handler ); // jQuery 1.3+
$( document ).delegate( selector, events, data, handler ); // jQuery 1.4.3+
$( document ).on( events, selector, data, handler ); // jQuery 1.7+
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
