i have component like this and want to set some attributes on it:
OlapApp.ItemRowsComponent = Ember.Component.extend({
tagName: 'li',
classNameBindings: ['currentItem.isMeasure:d_measure:d_dimension'],
didInsertElement: function() {
this.$().draggable({
});
},
actions: {
removeItem: function(item) {
item.deleteRecord();
item.save();
},
didClick: function(item) {
if (item.get('isMeasure')) {
item.deleteRecord();
item.save();
}
}
}
});
and i call this component like this :
{{#each item in getRowItem}}
{{item-rows currentItem=item}}
{{/each}}
item have a id property item.id
now i want to set this id to data-id of component to create an element like this :
<li data-id='id of item'>Some text</li>
Your approach actually works? I would suspect that it shouldn't work that way and should rather be:
OlapApp.ItemRowsComponent = Ember.Component.extend({
attributeBindings:["data-id"],
"data-id" : Ember.computed.oneWay("currentItem.id")
// and the rest of your code ...
});
One little extra remark: Checkout my blog post on how to perform jquery logic correctly: http://mavilein.github.io/javascript/2013/08/01/Ember-JS-After-Render-Event/
You can actually do it without introducing an extra computed property.
attributeBindings:['currentItem.id:data-id']
after searching and trying some way i find that . im using this for solve my problem :
attributeBindings:['getId:data-id'],
getId:function(){return this.get('currentItem.id')}.property(),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With