任何人都可以帮我如何添加一个双击编辑的功能。现在只需点击一下即可编辑
<script>
function showEdit(editableObj) {
$(editableObj).css("background","#FFF");
}
function saveToDatabase(editableObj,column,id) {
$(editableObj).css("background","#FFF url(ajax-loader.gif) no-repeat right");
$.ajax({
url: "update.php",
type: "POST",
data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,
success: function(data){
$(editableObj).css("background","#FDFDFD");
// $.notify('Document Updated',{close: true, color: "#fff", background: "#20D67B",animationType:"drop"})
}
});
}
</script>
答案 0 :(得分:0)
我假设您想在双击后调用showEdit函数,以便使该工作只需使用计数器变量来检查点击次数。
<script>
var clickCount = 0;
function showEdit(editableObj) {
clickCount++;
if(clickCount == 2){
$(editableObj).css("background","#FFF");
clickCount = 0;
}
}
function saveToDatabase(editableObj,column,id) {
$(editableObj).css("background","#FFF url(ajax-loader.gif) no-repeat right");
$.ajax({
url: "update.php",
type: "POST",
data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,
success: function(data){
$(editableObj).css("background","#FDFDFD");
// $.notify('Document Updated',{close: true, color: "#fff", background: "#20D67B",animationType:"drop"})
}
});
}
</script>