Live data from Hacker News

Stepping Backwards from AngularJS to JQuery – An Experiment

hundredminutehack.blogspot.com

21–30 of 68 posts

Re: Stepping Backwards from AngularJS to JQuery – An Experiment

#22

I think there's a better approach to handling the delete buttons that's pretty common when using jQuery. Instead of each button having it's own handler function I would specify an event handler on a single DOM element (e.g. a list container) with something like $('#itemlist').on('click', '.delete', deleteItem). When 'deleteItem' is called 'this' will be the clicked button element that could have an attribute like 'da…

yes, that is event delegation : https://learn.jquery.com/events/event-delegation/

Re: Stepping Backwards from AngularJS to JQuery – An Experiment

#24

Giving up Angular did force me to think more about the DOM. Vanilla jQuery doesn't insert itself as readily into HTML code as an Angular directive can. And that's why you should use http://intercoolerjs.org for most of your stuff, and a bit of jQuery where necessary for more exotic UX needs. The people who got sick of a mess of jQuery code were right, but they went the wrong direction to fix it. We have to go back. I…

Personally I welcome useful mentions of relevant alternatives in HN discussions, even if it's someone's own project.

I would encourage you to tone down your rhetoric a bit, though. Intercooler looks like a good lightweight tool for projects with lightweight requirements, but based on your own documentation, the claim that it covers most of what is needed for most modern web apps just hurts your credibility.

Re: Stepping Backwards from AngularJS to JQuery – An Experiment

#25

You can use event delegation for button handling : `$(document).on('click', '.button-list', my_function);` https://learn.jquery.com/events/event-delegation/

Thanks for posting this. It's sad how few people seem to know about event delegation...

Re: Stepping Backwards from AngularJS to JQuery – An Experiment

#26
post #6

Caveat: novice programmer here. Even Angular is still difficult for me to grok and sometimes I wonder if stuff that comes out of Google "suffers" (for me) from Google having unlimited resources and employing superior engineers? Would Google have a difficult time empathizing with "average" programmers with limited resources?

Angular is difficult to grok because it makes computer programming second class and limited to what you can cram into HTML tags. Angular isnt really a Google product - Misko Hevery and another guy (both Google SW Engineers) developed in their free time. Dart is a Google product and I would say is much easier to grok than Angular.

> Angular is difficult to grok because it makes computer programming second class and limited to what you can cram into HTML tags.

...say what? I've done a lot of work with Angular, and a lot of work without it, and it's possible that I might agree with what you're saying here if I understood it, but I don't. Can you elaborate?

Re: Stepping Backwards from AngularJS to JQuery – An Experiment

#27
post #6

Caveat: novice programmer here. Even Angular is still difficult for me to grok and sometimes I wonder if stuff that comes out of Google "suffers" (for me) from Google having unlimited resources and employing superior engineers? Would Google have a difficult time empathizing with "average" programmers with limited resources?

I think Angular takes a considerable amount of time to wrap your head around. I think the largest issues that you will most likely run into is an ng-repeat with large collection of objects (which, due to dirty checking, may impact your site), memory leaking, and using multiple controllers or controller as syntax.

I used Mithril for a while and it opened up my eyes as far as thinking "functionally"; it makes your code easier to understand and extend.

If you use filters functionally with Angular, you can get great performance on large collections in a ng-repeat. Likewise, if you understand prototypical inheritance, it will make working with multiple controllers/states a lot easier.

I really enjoy developing Angular, but it took a lot of time to really process. jQuery just works out of the box, but for me, it feels like it is more for little snippets of codes across various pages. It just depends on what you are trying to do.

Re: Stepping Backwards from AngularJS to JQuery – An Experiment

#28

I found this interesting because it seems to have been written by a person who learned Angular before jQuery. I haven't run into that before. Maybe I'm getting old.

Well, I actually learned Angular 2 before I learned Angular 1.

This is an extremely confusing statement, considering that Angular2 is only at RC5 and has had many major breaking changes to the API and core components ranging from 3 completely different router builds, introduction of NgModules, greater integration with Observables, a compiler still being developed, etc all since it left "Beta" in May.

I'd have to guess you left Angular2 to go back to Angular1 considering the current state of development

Re: Stepping Backwards from AngularJS to JQuery – An Experiment

#29

I found this interesting because it seems to have been written by a person who learned Angular before jQuery. I haven't run into that before. Maybe I'm getting old.

I have a suspicion that this kind of thing happens with programmers who have not worked much on client side development moving to it from Enterprise Java development or similar disciplines. This suspicion also seems to be borne out/hinted at by the post.

Re: Stepping Backwards from AngularJS to JQuery – An Experiment

#30

Giving up Angular did force me to think more about the DOM. Vanilla jQuery doesn't insert itself as readily into HTML code as an Angular directive can. And that's why you should use http://intercoolerjs.org for most of your stuff, and a bit of jQuery where necessary for more exotic UX needs. The people who got sick of a mess of jQuery code were right, but they went the wrong direction to fix it. We have to go back. I…

I hadn't heard of intercooler.js but that looks pretty awesome. Definitely going to check it out.
Post reply on HN