View Full Version : Help: ContentPanel not executing Javascript

6 Jan 2007, 5:54 PM
Hi All,

Firstly Jack this is the one of if not the best and easiest to use UI package I have come across. Keep up the good work.

I am newbie, just a couple hours into yui-ext and have gotten stuck.

I modified the complex layout example and used the setUrl for the ContentPanel to load a remote page that uses Javascript, however the javascript is not being executed, in some instances it actually displays the raw javascript code.

How can I get the javascript to be executed? What am I doing wrong?

Thanks in advance.


6 Jan 2007, 6:43 PM
Please either post some code the illustrates the problem. Or, better yet, post a link to a working example that shows the problem you're encountering. Without either, there's nowhere near enough information to try and help you troublehsoot the problem.

6 Jan 2007, 7:10 PM
You most likely have a syntax error. Post your code if you can't figure it out (or use Firebug and it will probably tell you exactly what the problem is).

6 Jan 2007, 7:36 PM
No prob.

Below is an example of what I am talking about


There are three tabs
1) Just displays regular html ( simple.html )
2) Calls javascript alert function ( javascript.html )
3) Attempts to load YUI-Widget - ( http://yui-ext.com/playpen/yui-ext.0.40/examples/dialog/msg-box.html )

2 and 3 don't work

Please take a look.


6 Jan 2007, 7:52 PM
It doesn't currently work at all (throws a JS error immediately when it tries to add the contentPanels because you're referencing an external URL on tab 3. You can't do cross-domain stuff in JavaScript. Make that reference local to your example and try again.

6 Jan 2007, 8:18 PM
As jeff said, the 3rd will bomb because you are calling cross domain (not allowed). To enable script loading, your will have to turn it on. You can turn on script loading globally:

YAHOO.ext.UpdateManager.defaults.loadScripts = true;

7 Jan 2007, 6:42 AM
Thanks Guys

I didn't expect the external link to work, just wanted to know if you guys had created something that overcame that restriction.

YAHOO.ext.UpdateManager.defaults.loadScripts = true;

Did the trick for the second tab.

The third, even though I have pointed everything locally, still doesn't load the yui-widget .... ( I am using the Basic Tabs demo found in the documentation).

Is there any other setting I need to set for it to work?

Also when it is loaded will it have access to pre-existing functions or be able to read/write attributes of other pre-existing yui-wdigets?


7 Jan 2007, 7:58 AM
You have

YAHOO.ext.EventManager.onDocumentReady(TabsExample.init, TabsExample, true);

in tabs-example.js.

This is never going to fire for dynamically loaded content. In dynamically loaded content, scripts are only executed when the content is ready - there's some code in Element.update to ensure that.

7 Jan 2007, 8:39 AM
Thanks Animal.

I think I understand what to do now.