Skip to content

Commit

Permalink
fixes bug in PaginatedCollectionView
Browse files Browse the repository at this point in the history
properly detaches scrollEvent

Change-Id: I0fc4e79360bffaa9fede1f0fc9de482cb1937000
Reviewed-on: https://gerrit.instructure.com/18445
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
QA-Review: Ryan Florence <ryanf@instructure.com>
  • Loading branch information
Ryan Florence committed Mar 12, 2013
1 parent 34e2b20 commit 99ed04a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
12 changes: 7 additions & 5 deletions app/coffeescripts/views/PaginatedCollectionView.coffee
Expand Up @@ -35,7 +35,7 @@ define [
# Adds a loading indicator element # Adds a loading indicator element


els: _.extend({}, CollectionView::els, els: _.extend({}, CollectionView::els,
'.loadingIndicator': '$loadingIndicator' '.paginatedLoadingIndicator': '$loadingIndicator'
) )


@optionProperty 'scrollContainer' @optionProperty 'scrollContainer'
Expand All @@ -57,6 +57,7 @@ define [


attachCollection: -> attachCollection: ->
super super
@collection.on 'reset', @attachScroll
@collection.on 'fetched:last', @detachScroll @collection.on 'fetched:last', @detachScroll
@collection.on 'beforeFetch', @showLoadingIndicator @collection.on 'beforeFetch', @showLoadingIndicator
@collection.on 'fetch', @hideLoadingIndicator @collection.on 'fetch', @hideLoadingIndicator
Expand All @@ -79,9 +80,11 @@ define [
# #
# @api private # @api private


attachScroll: -> attachScroll: =>
event = "scroll.pagination:#{@cid}, resize.pagination:#{@cid}" scroll = "scroll.pagination:#{@cid}"
@scrollContainer.on event, @checkScroll resize = "resize.pagination:#{@cid}"
@scrollContainer.on scroll, @checkScroll
@scrollContainer.on resize, @checkScroll


## ##
# Removes the scoll event from scrollContainer # Removes the scoll event from scrollContainer
Expand Down Expand Up @@ -113,7 +116,6 @@ define [
@detachScroll() @detachScroll()
super super



## ##
# Hides the loading indicator after render # Hides the loading indicator after render
# #
Expand Down
13 changes: 13 additions & 0 deletions app/stylesheets/utilities/_forms.scss
@@ -0,0 +1,13 @@
input[type=text].loading {
background-image: url('/images/ajax-reload-animated.gif');
background-repeat: no-repeat;
background-position: 98% center;
}

.paginatedLoadingIndicator {
background-image: url('/images/ajax-reload-animated.gif');
background-repeat: no-repeat;
background-position: center center;
height: 20px;
}

1 change: 1 addition & 0 deletions app/stylesheets/utilities/_main.scss
Expand Up @@ -19,3 +19,4 @@
@import "show_hide_opacity"; @import "show_hide_opacity";
@import "spacing"; @import "spacing";
@import "alignment"; @import "alignment";
@import "forms";
2 changes: 1 addition & 1 deletion app/views/jst/paginatedCollection.handlebars
Expand Up @@ -6,5 +6,5 @@
</p> </p>
{{/if}} {{/if}}


<div class="loadingIndicator"></div> <div class="loadingIndicator">Loading</div>


2 changes: 1 addition & 1 deletion app/views/jst/searchView.handlebars
@@ -1,4 +1,4 @@
<input type="text" class="inputFilterView" /> <input type="text" name="inputFilter" class="inputFilterView" />


<div class="collectionView"></div> <div class="collectionView"></div>


0 comments on commit 99ed04a

Please sign in to comment.