Announcement

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

#1 2005-05-09 09:32:41

Chuck
Xinha Community Member
Registered: 2005-02-25
Posts: 29

OnChange handler

Well, I searched both the forum and the tickets about this and seems there no post about it : Have you guys tried to use the onChange javascript handler on a xinha/htmlarea field? Things seems to work if I let my textarea field as a normal one but as soon as I switch it to a htmlArea field, my function doesn't get called and I can't warn the user about clicking a link before saving the changes...

Any tips about this or documentation I missed somewhere?

Thanks in advance

Offline

#2 2005-05-19 05:51:58

adam.jimenez
Xinha Pro
Registered: 2005-04-19
Posts: 50

Re: OnChange handler

has anyone found a solution for this?

Offline

#3 2005-05-19 06:48:55

niko
Xinha Authority
From: Salzburg/Austria
Registered: 2005-02-14
Posts: 338

Re: OnChange handler

you might take a look at this:
http://xinha.python-hosting.com//ticket/89

and my last comment


Niko

Offline

#4 2005-05-19 07:40:42

adam.jimenez
Xinha Pro
Registered: 2005-04-19
Posts: 50

Re: OnChange handler

Thanks Niko.

Is there any way to set this from outside xinha so that it won't be broken during an upgrade.

I tried:
window.xinha_editors.editor.onKeyPress = function() {somefunc();}

but it doesnt seem to do anything?

Offline

#5 2005-05-19 08:10:16

niko
Xinha Authority
From: Salzburg/Austria
Registered: 2005-02-14
Posts: 338

Re: OnChange handler

i did write a little plugin:

function CheckOnKeyPress(editor) {
    this.editor = editor;
}


CheckOnKeyPress._pluginInfo = {
    name          : "CheckOnKeyPress",
    version       : "1.0",
    developer     : "",
    developer_url : "",
    c_owner       : "Niko Sams",
    sponsor       : "",
    sponsor_url   : "",
    license       : "htmlArea"
};

CheckOnKeyPress.prototype.onKeyPress = function(ev) {
    editor = this.editor;
    var id = editor._textArea.id;
    var re = /_([0-9]+)$/;
    id = id.match(re);    
    checkRow(id[1]);
}

Last edited by niko (2005-05-19 08:10:52)


Niko

Offline

#6 2005-05-19 10:23:30

Chuck
Xinha Community Member
Registered: 2005-02-25
Posts: 29

Re: OnChange handler

That plugin did the thing nicely :-)

Thanks for taking the time to reply to this post !

Offline

#7 2005-05-20 08:18:19

adam.jimenez
Xinha Pro
Registered: 2005-04-19
Posts: 50

Re: OnChange handler

Works for me as well.

Thanks very much Niko.

Offline

#8 2005-05-20 09:58:50

adam.jimenez
Xinha Pro
Registered: 2005-04-19
Posts: 50

Re: OnChange handler

Hi,

I thought it was working but I get a blank textarea when I try to call the plugin.

I don't get any script errors.

Other plugins work fine.

I created a folder in the plugins dir called CheckOnKeyPress

and copied and pasted the plugin to a file called check-on-key-press.js in that directory.

I think I must be doing something dumb.

Offline

#9 2005-05-20 10:16:09

Chuck
Xinha Community Member
Registered: 2005-02-25
Posts: 29

Re: OnChange handler

You got me worried for a few seconds there... but, indeed, my texts/htmlareas are just fine.

I didn't put it into the plugins dir because I wished to keep it while I could update xinha independtly. I just put this code :

CODE
        <script type="text/javascript" language="javascript">
            function CheckOnKeyPress(editor) {
                this.editor = editor;
            }


            CheckOnKeyPress._pluginInfo = {
                name          : "CheckOnKeyPress",
                version       : "1.0",
                developer     : "",
                developer_url : "",
                c_owner       : "Niko Sams",
                sponsor       : "",
                sponsor_url   : "",
                license       : "htmlArea"
            };

            CheckOnKeyPress.prototype.onKeyPress = function(ev) {                               
                formChanged(); // My change handler for the whole form
            }
        </script>
ENDCODE

And added the plugin name in my plugin array before building the htmlareas and all is just fine

Offline

#10 2005-05-20 10:20:55

adam.jimenez
Xinha Pro
Registered: 2005-04-19
Posts: 50

Re: OnChange handler

thass more like it! Thanks Chuck. Much appreciated.

Offline

#11 2005-05-21 02:50:24

niko
Xinha Authority
From: Salzburg/Austria
Registered: 2005-02-14
Posts: 338

Re: OnChange handler

the file must be called check-onkey-press.js i think

check web-server-error logs on that....

....imho upgrading to a newer xinha-version should be no problem at all with a custom plugin - as you only have to copy the plugin-folder


Niko

Offline

#12 2005-09-10 11:54:18

loco00
New member
Registered: 2005-09-10
Posts: 3

Re: OnChange handler

Hi,
This is my first time posting here
NIko I couldn't get your plugin to fully work...

In the CheckOnKeyPress.prototype.onKeyPress = function(ev)

what is  checkRow(id[1]);?

also after
editor = this.editor;
    var id = editor._textArea.id;
how can i access the editor._textArea.value? I always get an empty string before using submiting button.

and last question...I suppose if the user copies and pastes text in the xinha area...with the mouse.....this will not be handled...
is there a way to handle that?
Or maybe the classic textarea "onchage" functionality has been restored, and i am not aware?

thanks so much guys for your help and the awesome xinha
alex





niko wrote:

i did write a little plugin:

function CheckOnKeyPress(editor) {
    this.editor = editor;
}


CheckOnKeyPress._pluginInfo = {
    name          : "CheckOnKeyPress",
    version       : "1.0",
    developer     : "",
    developer_url : "",
    c_owner       : "Niko Sams",
    sponsor       : "",
    sponsor_url   : "",
    license       : "htmlArea"
};

CheckOnKeyPress.prototype.onKeyPress = function(ev) {
    editor = this.editor;
    var id = editor._textArea.id;
    var re = /_([0-9]+)$/;
    id = id.match(re);    
    checkRow(id[1]);
}

Offline

#13 2005-09-13 03:06:42

niko
Xinha Authority
From: Salzburg/Austria
Registered: 2005-02-14
Posts: 338

Re: OnChange handler

hi,

the checkRow-function is a function from my CMS, you won't need it...

use editor.getHTML()


Niko

Offline

#14 2006-12-21 17:39:36

dcrosta
New member
Registered: 2006-12-21
Posts: 1

Re: OnChange handler

Just wanted to bump this, to see if there's a way to get behavior more like "onchange" -- clicking toolbar items can also change the content without using the keyboard, I'd like to be able to know whenever the content of the editor changes.

Offline

Board footer

Powered by FluxBB