Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emberjs bind data attributes

Tags:

ember.js

I am wondering if there is a way to bind data attributes in a template when calling a view.

For example (this doesn't work):

 {{ view App.SomeView data-dateBinding="currentDate" }}

I have ended up doing it this way:

<a {{bindAttr data-date="currentDate"}}></a>

There must be a way to do it when calling the view?

like image 518
Aaron Renoir Avatar asked Oct 09 '12 18:10

Aaron Renoir


1 Answers

More on the excellent answer from @kurt-ruppel.

An example using : to describe the property for attribute binding, entirely done from the view.

App.SomeView = Ember.View.extend({
  attributeBindings: ["date:data-date"],
  date: function() { return '1642-12-06' }
  .... rest of view
})

The cleaner template.

{{view App.SomeView}}
like image 174
captainpete Avatar answered Sep 27 '22 22:09

captainpete