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

AttachmentSize
user_titles5-task_js_array_structure.patch1.87 KB

#1

Gurpartap Singh - July 20, 2007 - 14:35

Oops, the above patch included the other patch related to Delete image src path.

AttachmentSize
user_titles5-task_js_array_structure_0.patch 1.88 KB

#2

merlinofchaos - July 20, 2007 - 18:23
Status:needs review» fixed

Thanks!

#3

Anonymous - August 3, 2007 - 19:01
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.