You are not logged in.
Hi,
When my page first loads, the textarea that I've got the Xinha code attached to shows up fine. When I use an AJAX function to load the textarea, it turns into a regular textarea.
Is there a way to re-initialize (?) the textarea as a Xinha textarea without reloading the screen?
Thank you,
Suzanne
Offline
If I get you right you want to load new contents in the editor. If that's the case, you don't have to insert a whole new textarea in the page. Use the Xinha method setHTML() instead.
var newHtml = "some HTML";
xinha_editors.myTextArea.setHTML(newHtml);
Offline
Worked like a charm! Thanks
Offline
Hi all,
I tried this and it didn't work. I have a basic HTML file that contains the following within the <head> section
<head>
<script src="myajaxfunctions.js" type="text/javascript"></script>
<script type="text/javascript">
_editor_url = "../" // (preferably absolute) URL (including trailing slash) where Xinha is installed
_editor_lang = "en"; // 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="../XinhaCore.js"></script>
<script type="text/javascript" src="XinhaConfig.js"></script>
</head>
and a <DIV id="main">editor will be here</DIV> within the <body>, then I have an AJAX function that I pass the URL I want to retrieve and the DIV I want to replace and it will put the contents returned from the URL directly into the DIV. Basically like this
<span onclick="myAJAXFunction('basic.php', 'main');">Click here to load editor</span>
I have the following PHP file that returns my form
code:
<?
echo '<form action="">
<div>
<textarea id="myTextArea" name="myTextArea" rows="10" cols="50" style="width: 100%">other stuff</textarea>
</div>
</form>
<script type="text/javascript">
var newHtml = "some HTML";
xinha_editors.myTextArea.setHTML(newHtml);
</script>';
?>
I know it is loading the form correctly because I am getting standard <textarea> but the Xinha editor is not loading.
Can someone please tell me what I am doing wrong!
Many thanks,
Forkie
Offline
i've struggled with this myself. i hid the textarea. then i put the initialization code (stuff in xinhaconfig.js) into the javascript function that shows the textarea. i also had to set a variable after i had been there once. otherwise, each time i show the textarea, it adds another editor.
Offline
Yeah, I'm trying to do the same and i believe I'm not the only one with this issue...gonna keep trying and if I got the answer, i'll let you know. In fact, i started a new post about the subject called "Xinha, Ajax, httpRequest object and innerHtml property".
Please keep in touch
Channis
Offline
This is a response to forkies code...
When I have tried doing javascript in an AJAX response, I have never been able to get it to work... though I didn't look too deep into it. Does the textarea with the sample JS actually show 'some HTML'?
If so (and the javascript is actually running), then the only thing I can think of is that you need to initialise the textarea just before you setHTML.
xinha_editors = xinha_editors ? xinha_editors :
[
'myTextArea'
];
After this, I think you need to somehow re-call the myconfig and xinhacore.js files. Perhaps something like this altogethor shoudl be returned...
<form action="">
<div>
<textarea id="myTextArea" name="myTextArea" rows="10" cols="50" style="width: 100%">other stuff</textarea>
</div>
</form>
<script type="text/javascript">
xinha_editors = xinha_editors ? xinha_editors :
[
'myTextArea'
];
var newHtml = "some HTML";
xinha_editors.myTextArea.setHTML(newHtml);
</script>
<script type="text/javascript" src="/PathToEditor/editor/XinhaCore.js"></script>
<script type="text/javascript" src="/PathToEditor/editor/myconfig.js"></script>
(You may need to adjust the positioning of the two tags above... I would expect AFTER the declaration of myTextArea but before the var newHTML. Also, it is assumed that myconfig.js does NOT have the declaration of the textarea. (I also think that the XinhaCore.js can be loaded at the top of the page rather than after the editor)).
Hope this helps.
Offline