40161ffc by Michael Richards

Merge pull request #162 from mikeric/scope-access-within-event-handlers

Scope/view access within event handlers
2 parents 421bf22b f05701d3
...@@ -251,8 +251,8 @@ class Rivets.View ...@@ -251,8 +251,8 @@ class Rivets.View
251 # Houses common utility functions used internally by Rivets.js. 251 # Houses common utility functions used internally by Rivets.js.
252 Rivets.Util = 252 Rivets.Util =
253 # Create a single DOM event binding. 253 # Create a single DOM event binding.
254 bindEvent: (el, event, handler, context) -> 254 bindEvent: (el, event, handler, view) ->
255 fn = (e) -> handler.call context, e 255 fn = (ev) -> handler.call @, ev, view
256 256
257 if window.jQuery? 257 if window.jQuery?
258 el = jQuery el 258 el = jQuery el
...@@ -364,7 +364,7 @@ Rivets.binders = ...@@ -364,7 +364,7 @@ Rivets.binders =
364 function: true 364 function: true
365 routine: (el, value) -> 365 routine: (el, value) ->
366 Rivets.Util.unbindEvent el, @args[0], @currentListener if @currentListener 366 Rivets.Util.unbindEvent el, @args[0], @currentListener if @currentListener
367 @currentListener = Rivets.Util.bindEvent el, @args[0], value, @model 367 @currentListener = Rivets.Util.bindEvent el, @args[0], value, @view
368 368
369 "each-*": 369 "each-*":
370 block: true 370 block: true
......