Javascript 如何在表/JQuery中保存事件后字段中的更新值?
现在,我的页面包含一组字段和用于编辑的表格脚本:Javascript 如何在表/JQuery中保存事件后字段中的更新值?,javascript,jquery,jeditable,Javascript,Jquery,Jeditable,现在,我的页面包含一组字段和用于编辑的表格脚本: <html> <head> <script type="text/javascript" src="jquery-1.7.2.min.js"></script> <script type="text/javascript" src="jquery.jeditable.js"></script> </head> <body> &l
<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.jeditable.js"></script>
</head>
<body>
<table border='1'>
<div id="load-button" style="border:1px solid black; background-color:white;padding:5px;cursor:pointer;width:200px;text-align:center;border-radius:4px;">Load button</div>
<script type="text/javascript" charset="utf-8">
$(function() {
$(".field").editable("echo.php", {
indicator : "<img src='img/indicator.gif'>",
tooltip : "Move mouseover to edit...",
event : "mouseover",
style : "inherit"
});
});
</script>
<?php
mysql_connect('localhost', 'root','') or die('connect');
mysql_select_db('jquery_test') or die('select_db');
$query=mysql_query('SELECT * FROM labels');
while ($data=mysql_fetch_assoc($query))
{
echo '<b class="field" style="display: inline">'.$data['text'].'</b><br >';
}
?>
</body>
</html>
加载按钮
$(函数(){
$(“.field”).editable(“echo.php”,{
指标:“,
工具提示:“将鼠标移到上方进行编辑…”,
事件:“鼠标悬停”,
风格:“继承”
});
});
但它不能正常工作:当我单击“按字段”时,输入新值并按“回车”,然后字段将其值更改为“单击编辑”,但我需要字段继续显示更新的值。我怎么做?我应该换什么 在您的jQuery代码中,我有类似的东西-它的.fnUpdate才是真正的关键部分
var tableElement = $(".field");
tableElement.editable("echo.php", {
style : "inherit",
"callback": function(sValue,y){
//Grab the cell position
var aPos = tableElement.fnGetPosition(this);
tableElement.fnUpdate(sValue, aPos[0], aPos[1]);
},{
"submitdata" : "OK"
});
tableElement.fnDraw();
另外,请告诉我,我可以从PHP脚本返回值吗?请向我们展示使用PHP生成的最终HTML。