vendredi 9 octobre 2015

Ember.js and DOM Manipulation

I am a week or so into Ember and am having some confusion about conventions with respect to jQuery DOM manipulation. So I know enough already that Ember is all about maintaining state, therefore from what I understand direct DOM manipulation with jQuery is a bad practice.

That being said, I've run into situations already where I could see where it could be useful, and didn't really understand the downsides.

To give an example, I am currently building an on-boarding 'tour guide' system, that will walk users through the UI. This involves toggling tabs, moving the guide window around the page (to be positioned beside other UI elements), and more. In one section there is a list of destinations, and I need to grab the first element from the list in order to target it and then place the tour guide window beside it. If I was just using jQuery, I could easily target the list element and then get the ID of the first element. With Ember, I would need to create an action on the list an bubble that action (seems arduous).

Similarly, I could easily use a jQuery click event to simulate clicking/toggling a tab in maybe one line of code. With Ember, the process involves creating a toggle action on that element and bubbling.

If someone could explain why or why not this is a bad practice that would great!




Aucun commentaire:

Enregistrer un commentaire