mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05: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:
parent
d3498483ab
commit
27e52c8979
1 changed files with 5 additions and 1 deletions
|
@ -13,7 +13,11 @@ var PostContentView = Ember.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
contentObserver: function () {
|
contentObserver: function () {
|
||||||
this.$().closest('.content-preview').scrollTop(0);
|
var el = this.$();
|
||||||
|
|
||||||
|
if (el) {
|
||||||
|
el.closest('.content-preview').scrollTop(0);
|
||||||
|
}
|
||||||
}.observes('controller.content'),
|
}.observes('controller.content'),
|
||||||
|
|
||||||
willDestroyElement: function () {
|
willDestroyElement: function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue