You are not logged in.
Pages: 1
I am using htmlarea 3 (not the xinha version - theres another thread about that!!).
I'm using several areas on one page, similar to the 2areas example. however i currently just looking at the 2areas example, removing any confusion with my code.
what i have done is changed a button to do insertHTML.
righttoleft: [ "Direction right to left", "ed_right_to_left.gif", false, function(e) {e.insertHTML("some text");} ]
when i click the button strange things happen.
if i have focus in the area, the text is inserted. If focus is in the 2nd area and i click the button on area 1, the text is inserted into area 2. if i click the button on area 2 with focus in area 1, the text is inserted in area 1. if neither have focus, the text is inserted on the main page.
what needs to be done to make the insertHTML command operate on the textarea that belongs to the button pressed - no matter where the focus is?
Thanks.
Offline
I'm not sure it's possible to insert code away from the focus without writing a different function to do so specifically (though I'm no javascript expert).
The built-in functions like insertHTML and surroundHTML rely on focus to determine where to insert/what to surround afaik.
A solution may be to have a handler function to check where the focus is when the button is clicked. If it's not in the right area, move the focus. But as I said I'm no javascript guru, so there may be a simpler answer
Offline
ok thanks.
anyone know how to tell which textarea's button was clicked and move the focus to the textarea?
i've been poking, and the inserttable fucntion works as expected, no matter where the focus is. that seems to use pasteHTML. i'll look down that route...
Offline
ok it seems to be working with this code
var sel = this._getSelection();
var range = this._createRange(sel);
var editor = this; // for nested functions
var doc = editor._doc;
var addendum = "inserted text"
if (HTMLArea.is_ie) {
range.pasteHTML(addendum);
} else {
editor.insertNodeAtSelection(addendum);
}
return true;
oh well!
Offline
What changes do I need to make to the Xinha code to get the old HTMLArea insertHTML function working?
With HTMLArea I could use:
<a href="javascript:editor_insertHTML('content','[[month]]');">month</a>
to insert a short-cut for automatically-replaced fields in my CMS, but this no longer works with Xinha.
Any suggestions??
Thanks!
Gill
Offline
Not so sure on using it in that context, but editor.insertHTML() should work (presuming you've declared editor as an HTMLArea somewhere)
Offline
...you use editor_inserHTML!
so do you have somewhere this function defined?
you might try editor.insertHTML (f you have editor defined)
Niko
Offline
Sorry, I don't understand Javascript and I've tried several different alternatives, but I don't know what I'm doing and I'm not making any progress. Any help you can give me, would be very gratefully received...
How do I declare/define editor as an HTMLarea? I've just installed Xinha by following the Newbie guide.
Does the function still exist? (It was a standard function in the old HTMLarea.)
Any other ideas about what I'm doing wrong or how to get the same result?
Thanks!
Offline
no, the functino doesn't exist, the funciton was just an example in the standard-example of htmlarea as far as i remembers.
if you used the newbieguide it may work like this:
xinha_editors['myTextArea'].insertHTML
Niko
Offline
Thanks Niko - much appreciated.
After much experimentation, I decided it was easier to create a plugin based on Character Map to do what I wanted.
So after a bit more experimentation, I am now the proud owner of an "InsertField" plugin. :-)
Offline
Pages: 1