Skip to content

Instantly share code, notes, and snippets.

@courtsimas
Created May 10, 2011 21:09
Show Gist options
  • Save courtsimas/965387 to your computer and use it in GitHub Desktop.
Save courtsimas/965387 to your computer and use it in GitHub Desktop.
$(".editable_question").each(function(){
//setup editing of owned questions
var args = {data: function(value, settings) {
// Unescape HTML
var retval = value
.replace(/&/gi, '&')
.replace(/>/gi, '>')
.replace(/&lt;/gi, '<')
.replace(/&quot;/gi, "\"");
return retval;
}};
$.extend(args, {
name : "question[body]",
submit : "Edit",
method : "PUT",
dataType : "json",
indicator : "Saving...",
tooltip : "Click to edit...",
callback : function(value, settings, original){
status = "alert" // set the initial status
if( value.status == 200 ){
$(this).html(value.body)
status = "notice"
}
else
$(this).html(original.revert);
//now build it
$.construct_flash_message(status, value.message);
}
});
$(".editable_question[data-name='question[body]']").editable("/questions/"+$(".editable_question").data('id'), args);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment