Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.5.2
-
Fix Version/s: 4.5.3
-
Component/s: Core CiviCRM, Extension System
-
Labels:None
-
Documentation Required?:None
Description
CRM_Core_Resources::singleton()->addSetting() allows a developer to add a setting to the global CRM javascript object. Unfortunately, if a form is loaded via AJAX, as with the Group settings pages (if clicked from /civicrm/group?reset=1&action=browse), those settings never get added to CRM.
I'm pretty sure this is because the settings are added to the "html-header" region and that region isn't reloaded when the form is loaded via AJAX.
The only way around this that I can think of is to either:
1. Go the old-school route and add the setting via a template variable. This requires all the JS that uses that setting be placed directly in the Smarty template, which is icky.
2. Use the addScript function to add the setting manually to the CRM object and set the region for it to "page-body". The problem with this is that it'll clobber any settings with the same namespace. I tried doing some stuff to merge the settings, but the mergeSettings function is protected, so I couldn't do that efficiently.
3. Use the addScript function to add some custom HTML with the data you want and then access the content within that HTML in the javascript file. This feels pretty icky, too.
For now, I think I'm going to go with option 2 as I'm not really worried about someone using the same namespace for the setting I'm adding.