Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2012-06-11 05:01:30

simba
New member
Registered: 2012-06-11
Posts: 2

How to recognize textarea added with XMLHttpRequest?

I include the Xinha javascript in the page header as required and it works, if i load the textareas with the normal content of the page.

<head>
    <script type="text/javascript">
        _editor_url  = "xinha/"   // (preferably absolute) URL (including trailing slash) where Xinha is installed
        _editor_lang = "en";       // And the language we need to use in the editor.
    </script>
    <script type="text/javascript" src="xinha/XinhaCore.js"></script>
    <script type="text/javascript" src="xinha/my_config.js"></script>
</head>

But I also need Xinha to work with textareas, which I add later dynamically to the page via an XMLHttpRequest.
Do I have to reinitialize the Xinha config after adding those textareas? And how would i do that?

Offline

#2 2012-06-12 04:08:36

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: How to recognize textarea added with XMLHttpRequest?

See Xinha.makeEditors() and Xinha.startEditors() in the XinhaCore.js

Pretty straightforward, make your textarea, insert it into the DOM, ensure the name & id of it are the same, supply this id to makeEditors, supply the result of makeEditors to startEditors.


James Sleeman

Offline

#3 2012-06-12 06:49:29

simba
New member
Registered: 2012-06-11
Posts: 2

Re: How to recognize textarea added with XMLHttpRequest?

Thanks alot, that pointed to the right direction.

Another problem was, that i used the xinha_editors object for supplying the textarea names. I noticed that it got nulled when the textareas were not found(i.e. directly after loading the page) and only reset when the page reloads, which never happens in my case.

I created a baseeditor object and copied it before the call.

xinha_editors = Object.create(xinha_baseeditors);
xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
Xinha.startEditors(xinha_editors);

Offline

Board footer

Powered by FluxBB