Announcement

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

#1 2006-04-24 15:24:50

MynameisMJ
New member
Registered: 2006-04-24
Posts: 5

Possible to enable xinha on dynamically created textarea?

Hi,

I've got xinha working great, but am wondering whether it was possible to get xinha to load with a dynamically created textarea.

Example:

JS Code:

var form = document.createElement('form');
    form.name = "editForm";
    form.action = "";
    form.method = "post";
    
    var ta = document.createElement('textarea');
    ta.name= "message";
    ta.setAttribute("id", "editMessage");
    ta.setAttribute("cols", "67");
    ta.setAttribute("rows", "6");
    ta.value = contents;
    e.innerHTML = "";
    
    var edit = document.createElement('input');
    edit.type = "button";
    edit.setAttribute("value", "Edit Post");
    edit.setAttribute("onclick", "editMessage();");
    e.appendChild(form);
    form.appendChild(ta);
    form.appendChild(edit);
    
//Enable xinhia --how?
    xinha_editors.editMessage.generate();

So it creates the form, but I can't figure out how to get xinha to recognize and generate it. Any ideas?

Offline

#2 2006-04-24 16:08:42

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Possible to enable xinha on dynamically created textarea?

var editor = null;
HTMLArea.loadPlugin("ImageManager");
HTMLArea.loadPlugin("SuperClean");

var config = new HTMLArea.Config();

config.toolbar =
[
    ["bold","italic","createlink","insertimage","separator"],
    ["killword","removeformat"]
];

config.formatblock =
{
    "— format —"  : "",
    "Heading 2": "h2",
    "Normal"   : "p"
};

function initEditor() {
  editor = new HTMLArea("wer_text",config);


  editor.registerPlugin(ImageManager);
  editor.registerPlugin(SuperClean);

  editor.generate();

}

I have copied this from an old "HTMLarea-like" config. It shows the steps you have to take before you can call  editor.generate(). (Thanks James for the simplification on this, btw smile )

Last edited by ray (2006-04-24 16:10:25)

Offline

#3 2006-04-24 16:13:08

MynameisMJ
New member
Registered: 2006-04-24
Posts: 5

Re: Possible to enable xinha on dynamically created textarea?

So in summary I'm going to need to make the configuration manually (rather then use config.js) so I can then generate the editor? Why didn't I think of that?

I'm off to test it. I'll post results after I test it. Thanks in advance!

Offline

#4 2006-05-11 14:15:40

MynameisMJ
New member
Registered: 2006-04-24
Posts: 5

Re: Possible to enable xinha on dynamically created textarea?

Sorry to post later - it did work.

Offline

Board footer

Powered by FluxBB