mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Back button wasn't reusing scroll position on category filter
This commit is contained in:
parent
fb4fb50b7b
commit
50005e2ef9
2 changed files with 12 additions and 8 deletions
|
@ -41,18 +41,21 @@ Discourse.FilteredListRoute = Discourse.Route.extend({
|
||||||
listController.load(this.filter).then(function(topicList) {
|
listController.load(this.filter).then(function(topicList) {
|
||||||
listController.set('canCreateTopic', topicList.get('can_create_topic'));
|
listController.set('canCreateTopic', topicList.get('can_create_topic'));
|
||||||
listTopicsController.set('model', topicList);
|
listTopicsController.set('model', topicList);
|
||||||
|
Discourse.FilteredListRoute.scrollToLastPosition();
|
||||||
var scrollPos = Discourse.Session.currentProp('topicListScrollPosition');
|
|
||||||
if (scrollPos) {
|
|
||||||
Em.run.next(function() {
|
|
||||||
$('html, body').scrollTop(scrollPos);
|
|
||||||
});
|
|
||||||
Discourse.Session.current().set('topicListScrollPosition', null);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Discourse.FilteredListRoute.reopenClass({
|
||||||
|
scrollToLastPosition: function() {
|
||||||
|
var scrollPos = Discourse.Session.currentProp('topicListScrollPosition');
|
||||||
|
if (scrollPos) {
|
||||||
|
Em.run.next(function() { $('html, body').scrollTop(scrollPos); });
|
||||||
|
Discourse.Session.currentProp('topicListScrollPosition', null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Discourse.ListController.filters.forEach(function(filter) {
|
Discourse.ListController.filters.forEach(function(filter) {
|
||||||
Discourse["List" + (filter.capitalize()) + "Route"] = Discourse.FilteredListRoute.extend({ filter: filter });
|
Discourse["List" + (filter.capitalize()) + "Route"] = Discourse.FilteredListRoute.extend({ filter: filter });
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,6 +35,7 @@ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
|
||||||
});
|
});
|
||||||
self.controllerFor('listTopics').set('content', topicList);
|
self.controllerFor('listTopics').set('content', topicList);
|
||||||
self.controllerFor('listTopics').set('category', category);
|
self.controllerFor('listTopics').set('category', category);
|
||||||
|
Discourse.FilteredListRoute.scrollToLastPosition();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue