Announcement

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

#1 2005-04-05 00:21:52

willeffects
Xinha Authority
Registered: 2005-03-19
Posts: 130

Function to execute javascript from a button

What function would I use to execute "javascript:preview(1)" from a button?

Thanks

Offline

#2 2005-04-05 00:35:57

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Function to execute javascript from a button

From what kind of button?  In the toolbar, or just a normal form button?

For the toolbar...

      xinha_config.btnList["my-preview"] =
       [ function(editor) { preview(1); }, // action
         "Preview?", // tooltip
         "my_preview.gif", // image
         false // disabled in text mode
       ];
      xinha_config.toolbar.push(["my-preview"]);

For a normal form button...

<button onclick="preview(1)" value="Da Button" />

James Sleeman

Offline

#3 2005-04-05 01:18:54

willeffects
Xinha Authority
Registered: 2005-03-19
Posts: 130

Re: Function to execute javascript from a button

Thanks James!

I was asking from the toolbar.  Is it posslbe to replace "1" with "editor" to pass the editor name?

like:
[ function(editor) { preview(editor); }, // action

?
Will

Offline

#4 2005-04-05 01:36:12

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

Re: Function to execute javascript from a button

sure, you can pass the editor-object to the preview-function...
but this is not the editor-name!
you can get the name of the textArea through:
editor._textArea.name
(i'm pretty sure this is not the correct and best way to get the name, but i didn't find a better one)


Niko

Offline

#5 2005-04-05 02:55:04

willeffects
Xinha Authority
Registered: 2005-03-19
Posts: 130

Re: Function to execute javascript from a button

thank you that worked!

Offline

Board footer

Powered by FluxBB