You are not logged in.
Pages: 1
I'd like to open a xinha editor for text editing (not HTML) so I want it to start in textmode instead of wysiwyg.
I see the default is hard-coded in the HTMLArea() function as
this._editMode = "wysiwyg";
I've tried setting the window.onload = my_init;
where my_init() is simply -
function my_init() {
xinha_init();
xinha_editors.text1.setMode();
}
but I get an error like
xinha_editors.text1 is null or not an object.
I can put a JS button on the screen and put the same xinha_editors.text1.setMode();
in the onclick and it works fine.
How can I get it to work at startup?
TIA
Steve
Offline
xiha_editors.etxt1 is null or not an object probably because it is too early to access them (settimeout to init iframes, plugins not all loaded, etc)
there's a "secret" function _onGenerate() called once the initialisation is completed
HTMLArea.prototype.initIframe = function()
{
...
...
// specific editor initialization
if(typeof editor._onGenerate == "function") {
editor._onGenerate();
}
}
I have made a quick page doing this, probably need some tweakings but i think it is one of the available ways to do it.
http://mokhet.com/xinha/examples/simple … otext.html
Basically, with your function my_init() it could look somethings like that
function my_init() {
xinha_init();
}
HTMLArea.prototype._onGenerate = function() {
// editor generated, we can switch to textmode
this.setMode('textmode');
return true;
}
It may work also with a simple setTimeout(), but I think you may have troubles if the initialisation is not completed.
function my_init() {
xinha_init();
setTimeout('xinha_editors.text1.setMode()', 1000);
}
But i also got the feeling Niko knows a much better way to do it
Offline
Thanks for the tips.
I read them first thing this morning but unfortunately in my world at work it takes me hours to do minutes of work with all the interruptions.
The setTimeout method worked for me. I did like the sound of the _onGenerate() solution better but couldn't get it to work.
I got a "HTMLArea is not defined" error when I tried to implement that.
While my current problem seems to be solved I'm still very much interested in getting _onGenerate() to work.
I read the source and it does appear to be a great "hook" to tap into for all sorts of future things.
Another thought I had from reading the source was that right now it appears that "wysiwyg" is hard-coded as the startup default.
It seems that it would be fairly easy to make this another config option to set prior to calling HTMLArea.startEditors().
(Someday I may be proficient enough to actually solve the problem instead of just suggesting solutions)
I really just started looking at this editor in the last week and must say that so far I like what I see.
I'm plan on using this as a replacement, not for a textarea, rather for an applet-based editor that replaced textareas in some of our code a couple of years ago. I've always hated our applet for it's lack of flexibility but the biggest problem has always been the incompatibility with Macs.
Xinha seems to be exactly what I've been searching for.
Offline
Pages: 1