Skip to content
Browse files

Pass jQuery object to callbacks (closes #4)

  • Loading branch information...
1 parent 5d4a2e3 commit 3212b54944b104b472d3b47e0b830ad51207a9b9 @kossnocorp committed Oct 15, 2012
View
5 spec/jquery.turbolinks_spec.coffee
@@ -31,6 +31,11 @@ describe '$ Turbolinks', ->
callback1.should.have.been.calledOnce
callback2.should.have.been.calledOnce
+ it 'should pass jQuery object to callbacks', ->
+ $(document).trigger('page:load')
+
+ callback1.should.have.been.calledWith($)
+
describe '$.setReadyEvent', ->
it 'should unbind default (page:load) event', ->
View
2 src/jquery.turbolinks.coffee
@@ -15,7 +15,7 @@ callbacks = []
# Call each callback in list
ready = ->
- callback() for callback in callbacks
+ callback($) for callback in callbacks
# Bind `ready` to DOM ready event
$(ready)
View
2 vendor/assets/javascripts/jquery.turbolinks.js
@@ -23,7 +23,7 @@
_results = [];
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
callback = callbacks[_i];
- _results.push(callback());
+ _results.push(callback($));
}
return _results;
};

0 comments on commit 3212b54

Please sign in to comment.
Something went wrong with that request. Please try again.