Hello, great module guys. One problem though: Colorbox Node is unfortunately filtering out script tags from nodes for some reason.

I'm not sure if it's a bug or some kind of protection. However, I really need that script tag on one of my nodes. Is there any way to include javascript with nodes?

Thank you. :)

Comments

stompeduns’s picture

Issue summary: View changes

Grammar.

iLLin’s picture

It doesn't strip out script tags. I have successfully put javascript into my node template and it fires just fine. Make sure you wrap what ever your trying to execute into an onready event.

stompeduns’s picture

@iLLin, I did it like this:

\<script type="text/javascript"\>
// global variables
jQuery(document).ready(function() {
	// code goes here etc.
});
\</script\>

Not working :(

EDIT: Wait code actually did execute, I tried a little "alert" and it ran just fine. It must be something in my code then. I think global variables shouldn't be in or outside the $.ready event. It causes trouble for some reason.

iLLin’s picture

Try this in your node template.

<script type="text/javascript">
(function ($) {
  $(document).ready(function() {
    alert('test');
  });
})(jQuery);
</script>

If that works, maybe you have a timing issue and you could try using setTimeout

stompeduns’s picture

@iLLin, it actually turns out to be a timing issue! But how come? I put my script at the bottom of the node, it should load right after all other elements. Colorbox seem to be rearranging the elements from the node.

iLLin’s picture

This module will load the contents of the ajax callback into a dom element on the page. It will then "move" that data into a colorbox "inline" style. Only way I could find to do this as colorbox doesn't interpret the json request as drupal does.

I have another idea to change this behavior but haven't had time to try it out. It will go hand in hand with the "loading instead of throbber" stuff I have been working on thats currently in DEV.

stompeduns’s picture

@iLLin, great I'll be waiting for a new realese. :)

Meanwhile, I'll be using setTimeout (which surprisingly worked pretty good).

patrickroma’s picture

Same issue here... How to display google adsense in a colorbox node?

iLLin’s picture

Status: Active » Fixed

changed more stuff up around this in the next DEV release, hopefully you shouldn't need to use setTimeout anymore.

stompeduns’s picture

Awesome, thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jglynn’s picture

I'm trying to add the google adwords conversion javascript to a webform confirmation page that is in a colorbox node.

I've added the javascript to the webform-confirmation.tpl.php, and it works fine on a normal webform page, but in a colorbox node the javascript tags are stripped out.

Is there anyway around this?

iLLin’s picture

Are you sure they are stripped out? Are you sure the webform-confirmation.tpl.php is used? Try installing the latest dev version 3.x-dev and then use the webform ajax module to make webforms AJAX. See if that will work for you.

b3nji’s picture

How do we use setTimeout?

b3nji’s picture

Issue summary: View changes

Changed

to script.