jeditable callback has empty values //OR// How to display edited text after clicking save button?

此生再无相见时 提交于 2019-12-31 02:59:11

问题


I have following code which attached and launches the editable properly on the div elements in the HTML table. the table is generated via ajax call. I am able to update the backend using the editable, but it is not updating the HTML table cell, which is being edited? for that i have to re-run the ajax query to redisplay the table with new values coming from backend. so my problem is essentially, to display the new value after successful submit.

to address my issue, i thought of using callback function, but I found value and settings are empty in callback function in the console log...

how can i fix my issue?

$(".edit_area").editable('/cgi-bin/mycgiscript.cgi', {
event       : 'dblclick',       //or dblclick
type        : 'textarea',
rows        : 2,
cols        : 30,
cancel      : 'Cancel',
submit      : 'Save',
indicator   : '<img src="images/indicator.gif">',
placeholder : 'Double Click to enter text',
tooltip     : 'Double Click to edit...',
name        : 'name',
id      : 'id',
callback    : function(value, settings) {
console.log('value='+value);
console.log('settings='+settings);
console.log('callback executed='+value);
return(value);
}
});

I used callback, because after 'SAVE'ing the edited text. The edited text is not displayed on the HTML page. It is properly being saved in the backend database. I have re run the ajax call which displays the updated information from the backend server...

editable is attached to the div in the html table which is being generated from an ajax call. if it helps...


回答1:


resolved: the way it works is: the ajax call of the function has to return something, which you can parse using the callback function. so once my ajax call started to spit out data. i was good.

tx all.




回答2:


Yes. Your AJAX function must return a String on which will be used on the textarea you just edited.

When I used this, my AJAX call returns 2 things, A Success/Fail flag, and the return message. I display the return message somewhere to notify the user that the operation is successful or not. I then use the callback function to actually update my target text area.



来源:https://stackoverflow.com/questions/12734124/jeditable-callback-has-empty-values-or-how-to-display-edited-text-after-clic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!