Da poco ho iniziato ad interessarmi a javascript e sto cercando di usare jquery ho trovato un esempio di edit in place e sto cercando di adattarlo, in pratica vorrei che cliccando su un bottone il testo diventasse editabile e apparisse il bottone salva, cliccando salva richiamare un file php dove svolgere le operazioni di salvataggio solo che non mi funziona qualcuno puo darmi una mano?
codice:$(document).ready(function(){ $("#body").each(function(i){ setClickable(this, i); }) }); function setClickable(obj, i) { $("#edit").bind('click', function(event) { $("#save_settings").show(); //hide the edit button $("#edit_settings").hide(); var textarea = '<textarea rows="4" cols="60">'+$("#body").html()+'</textarea>'; var revert = $(obj).html(); $(obj).after(textarea).remove(); $("#save").click(function(){saveChanges(this, false, i);}); $("#cancel").click(function(){saveChanges(this, revert, i);}); }) }//end of function setClickable function saveChanges(obj, cancel, n) { if(!cancel) { var t = $(obj).parent().siblings(0).val(); $.post("test.php",{ content: t, n: n },function(txt){ alert( txt); }); } else { var t = cancel; } if(t=='') t='(click to add text)'; $(obj).parent().parent().after('<div id="body">'+t+'</div>').remove(); setClickable($("#body").get(n), n); }Vorrei anche sapere se come posso passare l'id del messaggio dato che i messaggi sullapagina saranno piu di uno ognuno con il proprio id mentre cosi si ha solo un numero progressivocodice:<html> <head> <title>Hello!</title> <link rel="stylesheet" href="css.css" type="text/css" /> <script src="jquery.js" type="text/javascript"></script> <script src="jreplacev.js" type="text/javascript"></script> </head> <body> <div id="body">Edit the article body text here...</div> <div id="edit_settings"> <input id="edit" name="edit" value="edit" type="button"> </div> <div id="save_settings" style="display: none;"> <input id="save" name="save" value="save" type="button"> <input id="cancel" name="cancel" value="cancel" type="button"> </div> </body> </html>

Rispondi quotando
