Hi everybody,
I'm not exactly sure this question belongs here, so feel free to move it if the place is not the most proper one.
So, my problem is, I'm trying to write my first plugin using jquery, it's a form validator, and at a certain point it binds an handler to the submit event for that form:
- var that = this;
- console.log(this.element);
- this.element.bind(evt+"."+this.widgetEventPrefix, function() {
- console.log("form event triggered");
- return that.validateForm();
- });
- console.log("form event bound: "+evt+"."+this.widgetEventPrefix);
the problem is, when I click the submit button of the form, the event is NOT triggered, nor is the form submit, and I do not understand why...
for now, I've found this workaround:
- this.element
- .find(":submit")
- .click(function() {
- $(this).closest("form").submit();
- })
- .each(function() {
- try {
- this.type = "button";
- }
- catch (e) { }
- });
but I don't really like it, 'cause it seems so "dirty" to me...
Any idea of why the form submit is broken and how to "repair" it?