0
I am using ember view, once the page loads i want to scroll down to the page.In view didInsertElement will call and make the page load to scroll down, here is my code
App.MessagesView = Ember.View.extend({
didInsertElement: function() {
this._super();
var $target = $('.chat-area .chat-list')
, height = 0;
if ($target) {
$target.each(function(i, items_list) {
$(items_list).find('li').each(function() {
console.log($(this).height());
height = height + parseInt($(this).height());
});
});
$target.animate({ scrollTop: height});
}
}
更新所述屬性如果新其他消息被裝載之後但是,一旦在控制裝置,因爲該視圖已經被加載,所述滾動條不滾動至page.for其他消息。新的消息更新到計算的屬性,我想在DOM消息更新並調用scrolldown代碼後調用。如何滾動到DOWN使用餘燼
App.MessagesController = Ember.ArrayController.extend({
newmsgsCaptured: function(uuid) {
this.setProperties({
'newSelectedMessages': response,
});
var $target = $('.chat-area .chat-list')
, height = 0;
if ($target) {
$target.each(function(i, items_list) {
$(items_list).find('li').each(function() {
console.log($(this).height());
height = height + parseInt($(this).height());
});
});
console.log(height);
$target.animate({ scrollBottom: height});
}
}
});
after calling newmsgsCaptured 'acction', the property is updated with new data and the scrolled down is not working.
看看觀察者http://guides.emberjs.com/v2.0.0/object-模型/觀察員/ –