Block Specific CSS and JS?

Posts: 70
Joined: 04/14/2008

I've created a couple of custom blocks that are really nothing more than a few lines of JQuery code that make an ajax call to a local php file. I embedded the script in the block content itself, but was wondering if perhaps it would be better to make a separate JS file and include it in the theme template, perhaps? While I don't apply an custom CSS to this block, I could see a very similar situation coming up for applying CSS to a new block. What's the best way to handle this?

Also, has anyone seen failure of JQuery's load function in IE 5.5? I have it as a part of a setInterval for a periodic update, and it works fine in FF and Safari, but the content doesn't change in IE. Imagine that . . .

Posts: 70
Joined: 04/14/2008

Well, I think I figured out the issue with the .load() function. I have been working on the site at my place of employment and noticed the odd behavior while working in IE 5.5. I chalked it up to a IE issue, but checked it out in FF as well and saw identical behavior. Then it dawned on me . . . my employer uses a proxy server. Seems that would result in precisely what I'm seeing.

There may be no way around this, but any ideas on bypassing the proxy or at least forcing a refresh on its content?

Posts: 2243
Joined: 08/07/2007
AdministratoreLiTe!

Instead of the theme template, I'd go with a quick custom module to implement hook_block(). Any blocks you create that way can add their own CSS and JS, as well as getting their own sets of template files because they're in the same module. You might even get away with using include_once() on the PHP file.

Posts: 70
Joined: 04/14/2008

Thanks, Lyle. I don't know enough about module development and drupal yet, but I'm working on it!

As for the proxy issue, I think I've resolved it. I tagged the following to the beginning of my php file. Since the last proxy refresh it's been working like a champ.

header("Cache-Control: no-cache");

To me, that's the real beauty of Ubercart -- it's relatively simple to make things work just the way you want them to. It seems endlessly adaptable, which is terrific. Much better than any of the other CMS/cart solutions I've tried.

Excellent job, fellas. Terrific work you've done on Ubercart!