Now my page containts set of fields and JEditable script for editing:
<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>
But it doesn't work properly: when I click by field, input new value and press "enter" then the field changes his value to "Click to edit", but I need that fields continue to show updated value. How can I do it? What should I change?
In you jQuery code I have something like this - it's the .fnUpdate that really is the key part...
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.