jQuery form submit no longer works with Angular present

43 views
Skip to first unread message

Zach Hegwood

unread,
Dec 6, 2013, 5:25:55 PM12/6/13
to ang...@googlegroups.com
I have a legacy app that I'm retro-fitting with Angular.  Now that Angular is included, all of the jQuery form submits do not function.  form.on("submit",function(){ /*validate form*/ return true;}) and similar functionality is what I'm referring to... Basically any form where fields are validated through jQuery do not get submitted upon return true.

Adding ng-non-bindable is the only thing I've found as a workaround but the amount of work and testing necessary to make this change is not feasible.

Is this something that Angular is hoping to fix in a future release?  Is there something else I can do to make Angular not disable jQuery form submits in the meantime other than editing every form in my application?

Thanks,
-Zach

Sander Elias

unread,
Dec 7, 2013, 1:22:18 AM12/7/13
to ang...@googlegroups.com
Hi Zack,

I'm sorry, but this is not going to change! The form directive is an part of angular that's not going away. Form handling is one of angulars core responsibilities. 
You can't blame Angular for doing what it is designed to to ;-)
However, you might find that handling the validation with Angular is way less work then you might think. I have been where you are now, an opted for rewriting the forms to angular. Most of the work was in deleting obsolete code! 
In my situation the code handling the forms was reduced to 20% of the loc. Think about that! 

However, it is not that hard to monkeypatch your own angular into ignoring form attributes altogether. 

Regards
Sander

Michael Caputo

unread,
Dec 7, 2013, 3:31:53 AM12/7/13
to ang...@googlegroups.com
Would be great to provide some examples. I have recently had issues with angular post requests not behaving like query requests. Example $.POST data does not behave like $http.POST data.

Sander Elias

unread,
Dec 7, 2013, 3:46:46 AM12/7/13
to ang...@googlegroups.com
Hi Michael,

May I point out to you that $.Post is an jquery thing. It does not behave like XMLHttpRequest at all! As a developer you might be aware that not every library is behaving equally.
My personal view is that it is not an good idea to make everything look/behave like jquery. I do think jquery is a great library that does most of what it does in a good way, but that doesn't make it the truth of all things!

Regards
Sander

Michael Caputo

unread,
Dec 7, 2013, 3:53:40 AM12/7/13
to ang...@googlegroups.com
Absolutely I understand. However your previous comment outlining that Ajax requests in angular are 20% smaller is then deceiving, which is why I suggested an example.
The OP is asking for help making his Ajax requests behave like query.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/59tCRj52ZL4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Sander Elias

unread,
Dec 7, 2013, 4:10:23 AM12/7/13
to ang...@googlegroups.com
Michael,

Ahh, I should have expressed myself a bit more verbose! No, the requests are almost the same size, it is the validation, and handling of the form that is not 20, but almost 80% smaller. 

Regards
Sander
Reply all
Reply to author
Forward
0 new messages