Redactor WYSIWYG from: https://github.com/dybskiy/redactor-js
JQuery version: jquery-1.10.1.min.js (also tried 1.9.0 which comes bundled in demo)
Quite simple really, edit icon appears top right of content, onclick change content to WYSIWYG editor, also change icon to X for cancel
Onclick X, destroy editor, WYSIWYG editor back to original text
Following the quidance from this page: http://imperavi.com/redactor/examples/click-to-edit/ The difference is, I don't want 2 functions, I'm combining it into 1 function, depending on which class the editContainer has, will depend on which if-else is executed
Problem: .redactor('destroy'); does not work
<style>
#editContainer {
position: absolute;
right: 5px;
top: 5px;
width: 16px;
height: 16px;
}
#editContainer.edit {
background: url("../img/icon-edit-16.png") no-repeat 0 0;
z-index: 999;
cursor: pointer;
}
#editContainer.cancel {
background: url("../img/icon-error.png") no-repeat 0 0;
z-index: 999;
cursor: pointer;
}
</style>
<div id='headerRightContent'>
xxx
</div>
<div id='editContainer' class='edit' onclick=cmsEdit();></div>
<script type='text/javascript'>
function cmsEdit() {
if ( $('#editContainer').hasClass('edit') ) {
$('#headerRightContent').redactor({ focus: true });
$('#editContainer').removeClass('edit').addClass('cancel');
}else if ( $('#editContainer').hasClass('cancel') ) {
var html = $('#headerRightContent').redactor('get');
$('#headerRightContent').redactor('destroy');
$('#editContainer').removeClass('cancel').addClass('edit');
}
}
</script>
jQuery('#headerRightContent').redactor('destroy');? - EpokK$(.redactor).destroyEditor();- Richard Hedges