Thursday 15 January 2015

backbone.js - Adding and removing an EventListener from an event -


I'm not sure why when I present the scene, why does the event connect properly to the audience, but if I inside Attempts to add one This function of other events is undefined and throws errors. How do I get it to link the incident properly?

The solution is to add a variable that stores whether the mouse is down, but I think it is obvious to add and remove the event listener, it also requires the requirement of another variable of dislocation. Rejects.

Code:

  Render: function () {// Context Canvas. Context sets a new E.I.L. Laz platform. AddEventListener ("StationMudown", this.handleMouseDown); Canvas.Cantext Ed Event Listener ("ForumMouseUp", this.handleMouseUp); }, Handlemausdown: function () {console.log ('down'); Canvas.Cantext Ed Event Listener ("ForumMausomov", this.handleMouseMove); }, HandleMouseMove: function () {console.log ('moving'); }, HandleMouseUp: function () {console.log ('up'); Canvas.context.removieventelstiner ("ForumMausomov", this.handleMouseMove); }   

Error:

  Unkit type error: unchanged (9: 32: 29: 386 | error, javascript) property 'handleEvent' do not read Could .dispatchEvent (public_html / js / libs / easeljs-0.6.1.min.js: 14: 447) at b._handlePointerMove (public_html / js / libs / easeljs-0.6.1.min.js: 88: 490) b On ._handleMouseMove (public_html / js / libs / easeljs-0.6.1.min.js: 88: 69) at c.mousemove.f (public_html / js / libs / easeljs-0.6.1.min.js: 87: 34 )    

You need to do an _. BindAll (this) like your initially

  start: function () {_.bindAll (this);}  < / Pre> 

You should also be taken to initialize your event binding code because only once per instance will be called, while render can be repeatedly called, Resulting in duplicate event handler binding.

No comments:

Post a Comment