javascript - using custom jquery-events in ember.js -


i'm using custom jquery ui plugin in ember.js app, , react on custom jquery event in order update values of controller/model.

what found: question asked same purpose here on stackoverflow gives answer use jquery.bind()/[jquery.on() in the didinsertelement-function of view. use of jquery.on() in didinsertelement-method of view causes problem this inside event handler bound dom-element occurred on.

so ideally there way other jquery events work ones ember brings it: calling matching method names on ember.view- instance.

do know way custom jquery events work? possibly using mixin creating appropriate methods on view or like?

it sounds javascript issue, not jquery or ember issue. understanding , manipulating "this" bound 1 of biggest learning curves in javascript:

///...in view didinsertelement : function(){     var view = this;     this.$().zoomablebg(); //this name of custom jq ui-plugin     // view variable holds reference ember view     // , creates closure can refer in event handler     this.$().on("zoomablebgstopdrag", function(e){ view.zoomablebgstopdrag(e) }); }, zoomablebgstopdrag: function(b){     console.log(this); //this refers view now.  }, //more view code 

hope helps!


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -