ContentTools - 无法使用自定义编辑按钮重新激活
问题描述:
即时通讯使用ContentTools,并且所有内容在使用标准点火时均按预期工作。但是,当我不使用蓝色按钮添加自己的开始编辑/保存并放弃更改编辑器无法重新激活。这意味着用户可以编辑,然后保存一次。所有后续重新激活尝试失败都会失败。ContentTools - 无法使用自定义编辑按钮重新激活
初始化代码:
window.addEventListener('load', function() {
editor = ContentTools.EditorApp.get();
editor.init('.editable', 'id');
ContentTools.IMAGE_UPLOADER = imageUploader;
$('#btnStartEdit').click(function() {
editor.start();
$(this).hide();
$('#btnSaveChanges').fadeIn();
$('#btnDiscardChanges').fadeIn();
});
$('#btnSaveChanges').click(function() {
editor.save();
$('#btnStartEdit').fadeIn();
$('#btnSaveChanges').fadeOut();
$('#btnDiscardChanges').fadeOut();
});
$('#btnDiscardChanges').click(function() {
editor.revert();
$('#btnStartEdit').fadeIn();
$('#btnSaveChanges').fadeOut();
$('#btnDiscardChanges').fadeOut();
});
ContentTools.EditorApp.get()._ignition.unmount();
});
答
直接使用save()
和revert()
方法相反的,我建议你使用stop(true)
为保存和stop(false)
为取消/复原。
save
和revert
方法不会停止编辑器(例如save(true)
可用于在用户继续编辑时自动保存内容)。使用stop
应该允许你重新启动编辑器,例如:
window.addEventListener('load', function() {
editor = ContentTools.EditorApp.get();
editor.init('.editable', 'id');
ContentTools.IMAGE_UPLOADER = imageUploader;
$('#btnStartEdit').click(function() {
editor.start();
$(this).hide();
$('#btnSaveChanges').fadeIn();
$('#btnDiscardChanges').fadeIn();
});
$('#btnSaveChanges').click(function() {
editor.stop(true);
$('#btnStartEdit').fadeIn();
$('#btnSaveChanges').fadeOut();
$('#btnDiscardChanges').fadeOut();
});
$('#btnDiscardChanges').click(function() {
editor.stop(false);
$('#btnStartEdit').fadeIn();
$('#btnSaveChanges').fadeOut();
$('#btnDiscardChanges').fadeOut();
});
ContentTools.EditorApp.get()._ignition.unmount();
});
这样做的技巧和非常有意义,非常感谢! –