Hi Fred,
On Wed, Jan 2, 2013 at 10:46 AM, Fred <fred.pourfun(a)gmail.com> wrote:
Hi,
I'm trying to add some validations when the user save press the save button
on xwiki creation page.
What I added in actionButtons.js is that :
onSaveAndContinue : function(event) {
if (typeof(Wysiwyg) == 'undefined') {
return;
}
var editors = Wysiwyg.getInstances();
for(var hookId in editors) {
var editor = editors[hookId];
var plainTextArea = editor.getPlainTextArea();
}
alert(plainTextArea.value);
....
My problem is that I get an outdate value, meaning that for example, if in
my page I have :
a
b
c
And if I write "d" at the end, the alert return only :
a
b
c
Is there another better solution to get the text in
the WYSIWYG editor ?
It depends on what type of data your validations are expecting: rich
text (HTML) or plain text (Wiki syntax). In other words, what do you
want to validate, the (rich text) content of the WYSIWYG editor as it
is on the client (HTML) or the content that is saved on the database
(Wiki syntax). If you wish to validate the source then you need to
know that:
* each page can use a different wiki syntax so you may have to write
validations based on document syntax
* conversion from HTML to source is done on the server side and thus
you have to use an asynchronous API:
editor.getSourceText(onSuccessCallback, onFailureCallback)
To get the HTML instead, you need to use:
editor.getRichTextArea().contentWindow.document.body.innerHTML
Hope this helps,
Marius
Fred
--
View this message in context:
http://xwiki.475771.n2.nabble.com/Get-textarea-content-of-wysiwyg-in-javasc…
Sent from the XWiki- Users mailing list archive at
Nabble.com.
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users