summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-10-15 23:05:51 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2012-10-15 23:05:51 +0200
commita30aebb934bf35a58f08b3c9b196ecb4218fab56 (patch)
tree724f965e7a3f67c881d115371a14525c7b400feb
parent3075733665f62cf1b0fbf14f40ae9e25c55fcc82 (diff)
abort load request if a new feed is being loaded
-rw-r--r--js/items.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/js/items.js b/js/items.js
index 48ac53bdb..847647206 100644
--- a/js/items.js
+++ b/js/items.js
@@ -31,6 +31,7 @@ var News = News || {};
this._$articleList.scrollTop(0);
this._$articleList.children('ul').children('.feed_item:eq(0)').addClass('viewed');
this._itemCache = new ItemCache();
+ this._loadRequest = null;
this._setScrollBottom();
$(window).resize(function(){
@@ -89,6 +90,10 @@ var News = News || {};
* @param onSuccessCallback a callback that is executed when the loading succeeded
*/
Items.prototype.load = function(type, id, onSuccessCallback) {
+ if(this._loadRequest !== null){
+ this._loadRequest.abort();
+ }
+
this._lastActiveFeedId = id;
this._lastActiveFeedType = type;
@@ -102,7 +107,7 @@ var News = News || {};
this._$articleList.addClass('loading');
this._$articleList.children('ul').hide();
- $.post(OC.filePath('news', 'ajax', 'loadfeed.php'), data, function(jsonData) {
+ this._loadRequest = $.post(OC.filePath('news', 'ajax', 'loadfeed.php'), data, function(jsonData) {
// prevent loading in selected feeds that are not active any more when
// the post finishes later
if(self._lastActiveFeedType === type && self._lastActiveFeedId === id){