所以我的目标是允许用户点击列表中的项目,它会自动更改项目的值。大多数情况下,我希望用户能够轻松地将项目标记为正在阅读。此列表将每周更新,因此它将允许用户更容易地了解新内容。我已经设置了视图,因此用户只能在个人视图中看到自己的数据。
我在网上看过,但我没有好运。这是我到目前为止所做的。
<script src="https://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script><script type="text/javascript">
$(document).ready(function() {
$(".ms-listviewtable > tbody > tr").click(function(){ //only works before ajax runs
setTimeout( function() {
//alert("Hello! I am an alert box!!");
var ctx = SP.ClientContext.get_current("https://...");
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var clientContext = new SP.ClientContext();
var oList = clientContext.get_web().get_lists().getByTitle('Ticket');
this.oListItem = oList.getItemById(items[0].id);
this.oListItem.set_item('read','yes');
this.oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}, 200); //had to be put in place to give time for the list to be selected
});
});
这些是我的问题。
EDIT,
见下面的评论
答案 0 :(得分:0)
使用此代码:
$("table.ms-listviewtable").on("mouseup", "tr.ms-itmhover", function() {
//your code
});