Forums

How to use an external javascript library ?

Loko 09 Dec, 2008
Hi

I would like to use an external javascript library such as the Yahoo one (YUI) to design more user-friendly forms with tabs or accordions styles.

The problem is I need to run some javascript code after the html code because it requires the elements already exists in the DOM. But with ChronoForms the "Form javascript" section is always put before the "Form HTML" section.

Is there any possibility to achieve this anyway ? I can't put the javascript code at the end of the "Form HTML" section because it would be inserted inside the <form> tags and the won't work.

I guess I'll have to put the required javascript completly outside the chronoforms component, that is in an "html" plugin that would let me write some invisible html or javascript code, then put it on the same "web page", but how ? (I'm new to Joomla)

Thanks for any help.
Loko
GreyHead 09 Dec, 2008
Hi Loko,

I'd strongly recommend that you don't use the Yahoo library. Joomla 1.5 loads the MooTools library and - unless you are very careful - having the two libraries loaded will give rise to JavaScript conflicts.

MooTools supports tabs and accordions and both of these (and the other MooTools effects) can be used in Joomla and with ChronoForms.

If you do need to load a different JavaScript library (or any JavaScript), you can do this with the following Joomla code which will place a link into the page header.
<?php
$document = & $mainframe->getDocument();
$document->addScript('. . . script_path . . .');
?>

To delay the code I think you need to use the OnPageLoad event (from memory so probably incorrect).

Bob
Loko 09 Dec, 2008
Hi Bob

I didn't know. That's a great news for me ! I don't care using Yahoo or Mootools or any other librayry, I just need tabs and accordions.

I'll search for more informations about this (maybe into this forum ?) but I understand the "Form javascript" section is enough to use Mootols.

Thank you very much
Loko
GreyHead 09 Dec, 2008
Hi Loko,

The Library is usually loaded by Joomla - use FirebUg in FireFox to check. You will need to write the code to customise your form.

Bob
This topic is locked and no more replies can be posted.