Open GoogleCodeExporter opened 8 years ago
I have the same issue. For most of my AJAX stuff I return an object with
parameters. The values of the parameters determine what happens. How can I
access the returned object? Normally it would be whatever is returned by the
jQuery AJAX functions. You could do the same with your success function.
1. Submit a post to the server
2. Response returned by server should be passed to the success() callback if
the callback is defined. If not, then simply apply the response as you do now.
Thanks
Steve
Original comment by rhythmicdevil@gmail.com
on 22 Feb 2012 at 3:14
I made some changes to the code to get the effect that I wanted. I changed the
content of the success function to the following:
success: function(html){
var new_text = html || that.settings.default_text;
/* put the newly updated info into the original element */
// FIXME: should be affected by the preferences switch
//that.dom.html(new_text);
// REFACT: remove dom parameter, already in this, not documented, should be easy to remove
// REFACT: callback should be able to override what gets put into the DOM
//console.log('HTML', html);
that.triggerCallback(that.settings.success, that, html);
},
And this is how I implement it:
$('.editable').each(function(){
var editURL = $(this).closest('table').attr('editURL');
$(this).editInPlace({
'url' : editURL,
'callback_skip_dom_reset' : true,
'value_required' : true,
'success' : function(element, response){
if(response.status == 'success'){
$(this).html(response.msg.update_value);
}else{
$(this).html(element.originalValue);
$.popDialog(response);
}
}
});
});
This assumes that any table that has a custom attribute of editURL that has
children with a class of editable will have this applied. The change to the
success function allows me to access my response object which looks like
something like:
{
"title":"data",
"msg":{
"update_value":"cheeseburger.net",
"element_id":"undefined",
"original_html":"cheeseburger.coms",
"original_value":"cheeseburger.coms"
},
"status":"success"
}
The only other thing that I would like is to have a new function added to the
editor so that I can use a function to define the URL.
Steve
Original comment by rhythmicdevil@gmail.com
on 22 Feb 2012 at 4:08
Original issue reported on code.google.com by
Adrian.L...@gmail.com
on 19 Apr 2011 at 12:22