Closed (fixed)
Project:
Collapse Text
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
29 Jun 2012 at 01:13 UTC
Updated:
10 Aug 2012 at 16:21 UTC
Jump to comment: Most recent file
Reference #947710: Only add misc/collapse.js when needed..
Attached patch replaces 42 lines of code with one single line of code. You can simple use the #attached property to attach any javascript or css to any Form API item.
On top of this, the old method was not actually working on one site I tried this on.
Note this is Drupal 7 only.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 1664952_preprocess.patch | 2.14 KB | mstrelan |
| collapse_text_include_library.patch | 2.63 KB | mstrelan |
Comments
Comment #1
mstrelan commentedIt would appear that the theme function is only called after a cache flush because the filter is cached (obviously). This means you can't add the JS in the theme function, which I'm sure you already discovered, hence doing the preprocess.
I would suggest just add the JS on every page. It's going to be much more reliable and is only 3KB, and should be aggregated on production sites anyway. It also reduces the number of aggregate files that are created if the JS is on every page.
Comment #2
pukku commentedAt this point, I agree. It's getting to be more trouble than it's worth to not include the file.
I'm going to push a new version shortly with this change.
Thanks,
Ricky
Comment #3
pukku commented