Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Dynamic Css with EmberJS
    text
    copied!<p>I created this view </p> <pre><code>{{#view Q.FlashView id="flash-view"}} &lt;div class="row"&gt; &lt;div class="small-11 small-centered columns"&gt; &lt;div id="message" {{bindAttr class=":alert-box :radius"}} data-alert&gt; {{view.content.message}} &lt;a href="#" class="close"&gt;&amp;times;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; {{/view}} </code></pre> <p>with this definition </p> <pre><code>Q.FlashMessage = Ember.Object.extend({ type: "notice", message: null, isNotice: (function() { return this.get("type") === "notice"; }).property("type").cacheable(), isWarning: (function() { return this.get("type") === "warning"; }).property("type").cacheable(), isError: (function() { return this.get("type") === "error"; }).property("type").cacheable(), isSuccess: (function() { return this.get("type") === "success"; }).property("type").cacheable() }); Q.FlashView = Ember.View.extend({ contentBinding: "Q.FlashController.content", classNameBindings: ["isNotice: secondary", "isWarning: alert", "isError: alert", "isSuccess: success"], isNoticeBinding: "content.isNotice", isWarningBinding: "content.isWarning", isErrorBinding: "content.isError", isSuccessBinding: "content.isSuccess", </code></pre> <p>What I am trying to do is to make the view display the following css class depending on the type if notice for example to have class="alert-box radius notice".</p> <p>I can't figure out how is this done, as it seems this classNameBindings is not working out with static content. </p> <p>I already asked this question to the original author in which I took the code from, <a href="http://coderberry.me/blog/2013/06/20/using-flash-messages-with-emberjs/" rel="nofollow">coderberry.me/blog/2013/06/20/using-flash-messages-with-emberjs/</a> </p> <p>you can see the original code there.</p> <p>Thanks in advance </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload