mercredi 26 septembre 2018

Ember.js - classNameBindings is removing classes added from outside

When Ember recomputes the classes for a component through the classNameBindings attribute, it overwrittes any class added from outside, for example added by jQuery directly to the element.

Refactoring to get the classes added the "Ember way" through the classNameBindings is not an option, since I'm using an external jQuery plugin that adds them, perfect-scrollbar.

I suppose the problem happens because Ember doen't know about the classes added and just ignores them.

Is there a way/workaround for this kind of scenarios?


I put up a twiddle with a minimal working example of the problem here (if there is a way to get a working ember example using the code snippets, let me know and I edit)

One button toggles a class that changes the background color through de classNameBindings attribute, the other button uses jQuery to toggle a class that adds a green border. If the class through jQuery is added and then the ember button is pressed, the jQuery class is lost.




Aucun commentaire:

Enregistrer un commentaire