Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  103] [ 5]  / answers: 1 / hits: 38465  / 13 Years ago, mon, march 21, 2011, 12:00:00

I have a Backbone View that uses iScroll to implement a slideshow.



iScroll publishes an onScrollEnd event, but I cannot seem to bind/subscribe to it inside the View:



App.Views.Scroller = Backbone.View.extend({

events: {
'onScrollEnd' : 'scrollEnd'
},

initialize: function(){
var self = this;
this.scroller = new iScroll('content-scroller', {
onScrollEnd: function() {
self.trigger('onScrollEnd');
}
});
},

scrollEnd: function(e){
// never called :(
console.log(e);
}

});

More From » events

 Answers
11

Your onScrollEnd event is bound to the view's top element; scrollEnd will be called when the view's HTML element received an onScrollEnd event.



But you are triggering an onScrollend event on your View object, not the element.



So you probably want to say $(self.el).trigger('onScrollEnd'); instead, or perhaps call the function directly: self.scrollEnd().


[#93162] Saturday, March 19, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leighm

Total Points: 423
Total Questions: 101
Total Answers: 112

Location: Turkmenistan
Member since Sat, Apr 16, 2022
2 Years ago
;