<i>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.</i><p>And that's why you should use <a href="http://intercoolerjs.org" rel="nofollow">http://intercoolerjs.org</a> 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.<p>I know people get tired of my shilling, but intercooler really is a better way for many, and maybe most, web apps to be developed.
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 'data-itemid=123' which you use to fill in the 'id' part of the service call. And from there, after a successful service call, you can usually get at the parent element you want to remove from the list and take just that out instead of refreshing the entire list.<p>EDIT: Had the 'on' parameters mixed up. Here's the api doc: <a href="https://api.jquery.com/on/" rel="nofollow">https://api.jquery.com/on/</a>
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.<p>Maybe I'm getting old.
Next time, try dropping jQuery, too, and just using vanilla JavaScript. Just for fun. Simple DOM manipulation is now as simple in vanilla JavaScript as jQuery, with the only big advantage jQuery has now is if you're animating. You may find you're not missing much. You'd have to get used to slightly more involved Ajax syntax, unless you can target only new browsers, in which case the `fetch` API is just as convenient as jQuery's Ajax.<p>Heck, if you can can transpile to ES6 or if you're only targeting new browsers, you could probably even drop the Handlebars in factor of template literals without losing too much convenience.
Caveat: novice programmer here.<p>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?
You can use event delegation for button handling : `$(document).on('click', '.button-list', my_function);`<p><a href="https://learn.jquery.com/events/event-delegation/" rel="nofollow">https://learn.jquery.com/events/event-delegation/</a>
Just in case. I've written these while ago:<p>Routing, view, controllers in 60 lines of code + jQuery:
<a href="https://github.com/c-smile/spapp" rel="nofollow">https://github.com/c-smile/spapp</a><p>Template-less repeatable sections / lists in 100 lines of code + jQuery: <a href="https://github.com/c-smile/repeatable" rel="nofollow">https://github.com/c-smile/repeatable</a>.
Amazed at how Angular has created a generation of programmers that accept 2-way data binding and MVC as "the only way" to develop web apps.<p>JQuery encourages more fluent, purely functional reasoning, and one-way data binding of immutable data objects.
Step forward to ScalaJS and dont look back?<p><a href="https://www.scala-js.org/" rel="nofollow">https://www.scala-js.org/</a>