Created
May 10, 2011 21:09
-
-
Save courtsimas/965387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".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(/</gi, '<') | |
.replace(/"/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