Announcement

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

#1 2009-01-07 07:17:22

add
New member
Registered: 2009-01-07
Posts: 2

Get content with javascript

i have a rather old version of xinha in  a project and i cand get it to spit the content from the editor:

some code i use:

<script type="text/javascript">
    _editor_url  = "../xinha/"  // (preferably absolute) URL (including trailing slash) where Xinha is installed
    _editor_lang = "ro";      // And the language we need to use in the editor.
    _editor_skin = "silva";   // If you want use skin, add the name here
  </script>
  <script type="text/javascript" src="../xinha/XinhaCore.js"></script>
  <script type="text/javascript" src="../xinha/XinhaConfig.js"></script>

the config.js file

inha_editors=null;
xinha_init=null;
xinha_config=null;
xinha_plugins=null;




xinha_init=xinha_init?xinha_init:function(){
xinha_editors=xinha_editors?xinha_editors:["content","anotherOne"];
xinha_plugins=xinha_plugins?xinha_plugins:["CharacterMap","ContextMenu","ListType","Stylist","Linker","SuperClean","TableOperations"];
if(!Xinha.loadPlugins(xinha_plugins,xinha_init)){
return;
}
xinha_config=xinha_config?xinha_config():new Xinha.Config();
xinha_config.pageStyleSheets=[_editor_url+"examples/full_example.css"];
xinha_config.toolbar =
  [
    ["popupeditor","htmlmode"],
    ["separator","formatblock","fontsize","bold","italic","underline","strikethrough"],
    ["separator","forecolor","hilitecolor","textindicator"],
    ["separator","subscript","superscript"],
    ["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"],
    ["separator","insertorderedlist","insertunorderedlist","outdent","indent"],
    ["separator","inserthorizontalrule","createlink","insertimage","inserttable"],
    ["separator","undo","redo","selectall"], (HTMLArea.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]),
    ["separator","killword","removeformat","toggleborders","lefttoright", "righttoleft","separator"]
  ];

xinha_editors=Xinha.makeEditors(xinha_editors,xinha_config,xinha_plugins);
Xinha.startEditors(xinha_editors);
};
Xinha._addEvent(window,"load",xinha_init);

and i want to retrieve the content with:

var editor = Xinha.getEditor("content");
var html = editor.getEditorContent();

The error:

Xinha.getEditor is not a function

any idea what am i doing wrong?

Offline

#2 2009-01-07 07:58:49

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

Re: Get content with javascript

add wrote:

i have a rather old version of xinha

That will be the problem, as Xinha.getEditor() is a rather new function. You can instad use

var editor = xinha_editors["content"];
var html = editor.getEditorContent();
//if editor.getEditorContent() doesn't exist either, this will do
var html = editor.outwardHtml(editor.getHTML());

Offline

#3 2009-01-07 08:30:17

add
New member
Registered: 2009-01-07
Posts: 2

Re: Get content with javascript

thanks, it worked with

var editor = xinha_editors["content"];
var html = editor.getEditorContent();

Offline

Board footer

Powered by FluxBB