Better data array structure in drupal_add_js(.., 'settings')
Gurpartap Singh - July 20, 2007 - 14:33
| Project: | User titles |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | minor |
| Assigned: | Gurpartap Singh |
| Status: | closed |
Description
drupal_add_js(array('UserTitlesImageURL' => base_path() ."$path/delete.gif"), 'setting');
To make the array keys more unique(per module), it can be good to use:
array('userTitles' => array('imageURL' => base_path() ."$path/delete.gif"))
and access it in JS as: Drupal.settings.userTitles.imageURL
Really minor but couldn't resist. :P
| Attachment | Size |
|---|---|
| user_titles5-task_js_array_structure.patch | 1.87 KB |

#1
Oops, the above patch included the other patch related to Delete image src path.
#2
Thanks!
#3