我目前正致力于使用Backbone的消息传递系统.我想滚动到渲染上的CollectionView中的最后一个元素.
单击页面上的链接后我可以使用它,但我希望它在视图的渲染上发生.
这是我在链接中使用的,它有效:
document.getElementById('message-new-conversation-dialog').scrollIntoView();
Run Code Online (Sandbox Code Playgroud)
这是视图定义:
var ConversationView = LSmixBB.CollectionView.extend({
itemView: MessageView,
template: "#message-conversation-template",
onRender: function(){
document.getElementById('message-new-conversation-dialog').scrollIntoView();
document.getElementById('global-column-middle-footer1').scrollIntoView();
}
});
Run Code Online (Sandbox Code Playgroud)
我认为它不起作用,因为onRender里面的页面上什么都没有?
我对网络开发很新,所以要温柔!
无论如何,我真的很感激任何帮助!
我坚持这个.我有两个表:Users2Users和ActivityLog.我想查找作为用户朋友的Users2Users列表,并根据其Timestamp返回每个最新活动,然后检查它是什么类型.
Users2Users
int UserId
int TypeOfLink
int FriendId
ActivityLog
int Type
int UserId
DateTime Timestamp
Run Code Online (Sandbox Code Playgroud)
似乎令我不安的是获取ActivityLog实体而不是Timestamp值.
我的friendList查询如下所示:
var friendList = (from u in db.Users2Users
where u.UserId == userId || u.FriendId == userId
&& u.TypeOfLink == 2 // confirmed as friend
orderby u.User.ScreenName ascending
select u).Distinct().ToList();
Run Code Online (Sandbox Code Playgroud)
之后我打算尝试一个foreach,但是如何返回ActivityLog实体而不是Timestamp呢?
// get their last activity
foreach (var user in domusers)
{
var act = (from a in db.ActivityLogs
where a.UserId == user.UserId
select a.Timestamp).Max();
// other stuff
}
Run Code Online (Sandbox Code Playgroud)