88 * @version 2.3.9
99 * @requires jQuery v1.4.3+
1010 * @preserve
11+ *
12+ * BUGFIX by Christoph Illnar, COMMUNITOR
1113 */
1214( function ( $ ) {
1315
2628 contentSelector : '' ,
2729 pagingSelector : '' ,
2830 callback : false
29- }
31+ } ,
32+ instances : 0
3033 } ;
3134
3235 // Constructor
7477
7578 // Remove the jscroll behavior and data from an element
7679 _destroy = function ( ) {
77- return _$scroll . unbind ( '.jscroll' )
78- . removeData ( 'jscroll' )
80+ var data = $e . data ( 'jscroll' ) ;
81+ // don't do anything when called on an uninitialized element
82+ if ( ! data ) {
83+ return ;
84+ }
85+ $e . removeData ( 'jscroll' ) ;
86+ return _$scroll . unbind ( '.jscroll.instance_' + data . id )
7987 . find ( '.jscroll-inner' ) . children ( ) . unwrap ( )
8088 . filter ( '.jscroll-added' ) . children ( ) . unwrap ( ) ;
8189 } ,
95103
96104 if ( ! data . waiting && iTotalHeight + _options . padding >= $inner . outerHeight ( ) ) {
97105 //data.nextHref = $.trim(data.nextHref + ' ' + _options.contentSelector);
98- _debug ( 'info' , 'jScroll:' , $inner . outerHeight ( ) - iTotalHeight , 'from bottom. Loading next request...' ) ;
106+ _debug ( 'info' , 'jScroll[' + data . id + '] :', $inner . outerHeight ( ) - iTotalHeight , 'from bottom. Loading next request...' ) ;
99107 return _load ( ) ;
100108 }
101109 }
105113 _checkNextHref = function ( data ) {
106114 data = data || $e . data ( 'jscroll' ) ;
107115 if ( ! data || ! data . nextHref ) {
108- _debug ( 'warn' , 'jScroll: nextSelector not found - destroying' ) ;
116+ _debug ( 'warn' , 'jScroll[' + data . id + '] : nextSelector not found - destroying') ;
109117 _destroy ( ) ;
110118 return false ;
111119 } else {
115123 } ,
116124
117125 _setBindings = function ( ) {
118- var $next = $e . find ( _options . nextSelector ) . first ( ) ;
126+ var $next = $e . find ( _options . nextSelector ) . first ( ) ,
127+ data = $e . data ( 'jscroll' ) ;
119128 if ( ! $next . length ) {
120129 return ;
121130 }
127136 if ( scrollingHeight <= windowHeight ) {
128137 _observe ( ) ;
129138 }
130- _$scroll . unbind ( '.jscroll' ) . bind ( 'scroll.jscroll' , function ( ) {
139+ _$scroll . unbind ( '.jscroll.instance_' + data . id ) . bind ( 'scroll.jscroll.instance_' + data . id , function ( ) {
131140 return _observe ( ) ;
132141 } ) ;
133142 if ( _options . autoTriggerUntil > 0 ) {
134143 _options . autoTriggerUntil -- ;
135144 }
136145 } else {
137- _$scroll . unbind ( '.jscroll' ) ;
138- $next . bind ( 'click.jscroll' , function ( ) {
146+ _$scroll . unbind ( '.jscroll.instance_' + data . id ) ;
147+ $next . bind ( 'click.jscroll.instance_' + data . id , function ( ) {
139148 _nextWrap ( $next ) ;
140149 _load ( ) ;
141150 return false ;
151160 data . waiting = true ;
152161 $inner . append ( '<div class="jscroll-added" />' )
153162 . children ( '.jscroll-added' ) . last ( )
154- . html ( '<div class="jscroll-loading" id=" jscroll-loading">' + _options . loadingHtml + '</div>' )
163+ . html ( '<div class="jscroll-loading jscroll-loading-' + data . id + ' ">' + _options . loadingHtml + '</div>' )
155164 . promise ( )
156165 . done ( function ( ) {
157166 if ( _options . loadingFunction ) {
198207 } ;
199208
200209 // Initialization
201- $e . data ( 'jscroll' , $ . extend ( { } , _data , { initialized : true , waiting : false , nextHref : _nextHref } ) ) ;
210+ $e . data ( 'jscroll' , $ . extend ( { } , _data , { initialized : true , waiting : false , nextHref : _nextHref , id : ++ $ . jscroll . instances } ) ) ;
202211 _wrapInnerContent ( ) ;
203212 _preloadImage ( ) ;
204213 _setBindings ( ) ;
224233 } ) ;
225234 } ;
226235
227- } ) ( jQuery ) ;
236+ } ) ( jQuery ) ;
0 commit comments