Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Created August 27, 2013 03:24
Show Gist options
  • Select an option

  • Save clouddueling/6349328 to your computer and use it in GitHub Desktop.

Select an option

Save clouddueling/6349328 to your computer and use it in GitHub Desktop.
editable redactor
$('.redactor-editable').on('click', function(){
var target = $(this).data('target'),
pk = $(this).data('pk'),
name = $(this).data('name'),
url = $(this).data('url');
if ($(this).html() == 'Save') {
var value = $(target).getCode();
$(target).destroyEditor();
$.post(url, {
pk: pk,
value: value,
name: name,
});
$(this).html('Edit');
} else {
$(target).redactor({
focus: true,
});
$(this).html('Save');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment