Every time I do a postback, the CE:Editor class loses all the customisations that I've made:
- Reconfiguring the toolbar. This is merely an annoyance, as I can reset the toolbar on every postback.
- No longer traps the CuteEditor_OnCommand javascript event. This is what I'm trying to fix.
Here's my use case: I have a form where the user can select from a drop down list that names various images that are available. All of these are stored in a SQL database. I want to be able to trap the OnCommand event so that if they have selected InsertImage, I can have my custom code insert an <img> link instead of bringing up the usual "pick from these uploaded images" option.
My javascript is essentially:
function CuteEditor_OnCommand(editor, command, ui, value) {
alert("Command is " + command);
if (command == "InsertImage") {
alert("HERE");
insertImage();
return true;
}
return false;
}
insertImage is my method. I've left in the alerts for illustrative purposes; as you can see, the basic idea is that the InsertImage command is hijacked, and all others should pass through. When I first load the page, this works fine. But if I use anything that triggers a postback, then from that point onwards this javascript no longer gets executed.
I suspect that I need to restore the callback when I reapply all the configuration changes, but I'm not sure what the property is. I'm also not 100% certain what version of CuteEditor this is, as I'm not sure where that information is stored, but I believe it's version 6.
Any ideas? I'd be ecstatic if someone could clue me in on how to avoid losing everything on postbacks, but I'd be reasonably happy if I could just find a workaround to restore the javascript client event.