question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DEPRECATION: The `bind-attr` helper

See original GitHub issue

In ember 1.13.x and 2 beta, bind-attr is deprecated.

Any idea when this will be resolved?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mixoniccommented, Jul 10, 2015

@hwhelchel bind-attr will be removed in Ember.js 2.0. Unfortunately it seems like there is no entry in the deprecation guide for this.

You should replace bind-attr statements with htmlbars-style attribute bindings. For example:

<div {{bind-attr data-something=someBinding}}></div>

Can be rewritten as:

<div data-something={{someBinding}}></div>

The more complex case of a class binding:

<div {{bind-attr class="isActive:active:disabled"}}></div>

Can be rewritten as:

<div class={{if isActive "active" "disabled"}}></div>

Multiple bindings can of course be used. A complex example:

<div 
  class="{{if isActive "active"}} {{unless isTall shortClassName}}"
  data-something={{if isActive (t "active") (t "disabled)}}
  ></div>

The latter above demonstrating use of a 3rd party t helper for translation. This unified style of bindings is easier for new developers to learn (though us old hands may miss bind-attr) and simpler (no special syntax for class).

1reaction
samtescommented, Jan 14, 2016

What about concatenated classnames? How would you do it in HTMLBars?

<a {{bind-attr class="latestUser:descending latestUserOrder:ascending"}} href="#orderBy"> Latest user </a>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ember bind-attr deprecated, how to rewrite using new ...
I'm an Ember newbie, and am trying to alter the following handlebars/template line of code to not use the deprecated bind-attr approach ...
Read more >
Deprecations Added in Ember 1.x
bind-attr. Ember 1.11 introduced new syntax for using dynamic content in attributes. In 1.10 your only option was to use the bind-attr helper:...
Read more >
Expressions | Handlebars
Handlebars expressions are the basic unit of a Handlebars template. You can use them alone in a {{mustache}} , pass them to a...
Read more >
legacy-bind-attr - Ember Observer
Ember 2.0 deprecated {{bind-attr}} . This addon enables the bind-attr helper within your Ember 2.0 applications.
Read more >
What's New in Ember 2.0? - SitePoint
ArrayController and ObjectController have been deprecated in favor ... In past, the {{bind-attr}} helper was used to bind properties to DOM ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found