1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

Only attempt to scrollTop if element is available.

In later versions of Ember, the views and components can be stable
and are not guaranteed to be torn down before a new controller is
set on them.

In this case, the controller is initially set before the element has been
rendered to the DOM causing errors when invoking `closest` on undefined.
This commit is contained in:
Robert Jackson 2015-05-05 15:38:57 -04:00
parent 9250273d8d
commit a0a1763137

View file

@ -13,7 +13,11 @@ var PostContentView = Ember.View.extend({
},
contentObserver: function () {
this.$().closest('.content-preview').scrollTop(0);
var el = this.$();
if (el) {
el.closest('.content-preview').scrollTop(0);
}
}.observes('controller.content'),
willDestroyElement: function () {