Re: Javascript not running Joomla2.5

148 views
Skip to first unread message
Message has been deleted
Message has been deleted

Nicholas Brick

unread,
Mar 29, 2012, 7:45:38 PM3/29/12
to joomla-de...@googlegroups.com
I have a problem getting some simple Javascript to work in a custom component I am building

I have a simple onclick="runthisfunction()" attribute added to a form checkbox

I precede this with
     $document = &JFactory::getDocument();
     $document->addScript("components/com_myone/mycode.js");    
and that seems to load my js file correctly into the head section

The action of runthisfunction() is simply an alert("hello World") and I've tested it in a simple html file, works everytime

However, when in the midst of my Joomla component, When I run this and click on the checkbox nothing happens
Everything looks ok when I view source or inspect with Firebug

The mycode.js has been loaded in the head section
The checkbox in the form has the onclick="runthisfunction()" in place

but nothing happens, no errors, no crash, no alert
I've checked and double checked for spelling of case issues, all is fine

This is my 1st attempt to include JS within my component, so most likely my own mistake but I cannot see it
any help gratefully received, is there something I'm overlooking ?

Thx

Rouven Weßling

unread,
Mar 29, 2012, 7:54:21 PM3/29/12
to joomla-de...@googlegroups.com
Could you set up a test site and share the link? That'd make it far easier to figure out what's going on.

Rouven
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/zL0alMeXLJwJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Nicholas Brick

unread,
Mar 29, 2012, 8:55:05 PM3/29/12
to joomla-de...@googlegroups.com
Thanks Rouven, got to the bottom of it
I had included <script> tags in my .js file, took them out problem went away
It showed up when I tried using the Firebug console
Much appreciate the offer of help. Thx

Nick
Reply all
Reply to author
Forward
0 new messages