Reputation: 7919
im trying to using jquery drag and drop and i want to using some tools of ember in my view but i cant .
App.myView = Ember.View.extend({
tagName:'li',
didInsertElement:function(){
this.$().draggable({
start:function(event,ui){
console.log(this.get('tagName'));
}
});
}
});
but i get an error :
Uncaught TypeError: Object #<HTMLLIElement> has no method 'get'
can i use methods like get/set or other in didInsertElement in jquery section ?
Upvotes: 0
Views: 477
Reputation: 23322
this
inside the jQuery draggable initialization object does not refer to the view anymore, therefore you should first store this
in a local variable like self
so you can use it later on, try this:
App.myView = Ember.View.extend({
tagName:'li',
didInsertElement:function(){
var self = this;
this.$().draggable({
start:function(event,ui){
console.log(self.get('tagName'));
}
});
}
});
Hope it helps.
Upvotes: 5