Attribute binding at application startup

When I first launch the application and load the application, I try to bind to logical attributes in order to conditionally set the CSS class. Boolean attributes are initialized correctly, but the class is not set. As a rule, binding works after launch. Here is a JSFiddle that demonstrates the problem. Any ideas why this fails on first run?

+1
source share
2 answers

I got a response from the ember.js team on GitHub.

Here is Christopher Selden's answer ...

Your template outputs 2 class attributes, and when jQuery introduces it to the DOM, it removes> the last one, it does not combine them. After that, the binding updates the attribute in the DOM. If you need a static class and a related class, you need to put the static class in bindAttr with the help {{bindAttr class = ": something isB: redbg: greenbg"}}

http://jsfiddle.net/krisselden/uWJWh/9/

+3
source

Why not put redbg in conditions?

http://jsfiddle.net/uWJWh/4/

edit: Updated jsfiddle to use toggleProperty

http://jsfiddle.net/uWJWh/5/

+1
source

Source: https://habr.com/ru/post/927511/


All Articles