This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/mixins/url-refresh.js.es6
2014-07-24 14:59:53 -04:00

20 lines
638 B
JavaScript

// A Mixin that a view can use to listen for 'url:refresh' when
// it is on screen, and will send an action to the controller to
// refresh its data.
//
// This is useful if you want to get around Ember's default
// behavior of not refreshing when navigating to the same place.
export default Em.Mixin.create({
_initURLRefresh: function() {
this.appEvents.on('url:refresh', this, '_urlRefresh');
}.on('didInsertElement'),
_tearDownURLRefresh: function() {
this.appEvents.off('url:refresh', this, '_urlRefresh');
}.on('willDestroyElement'),
_urlRefresh: function() {
this.get('controller').send('refresh');
}
});