Settings
Settings in UI widgets are any part of a widget definition which is mutable. Most UI widgets have a set of common settings which are useful across all plugins.
Common Settings
Name | Usage | |
---|---|---|
name | Name used in debug logs to differentiate this widget from other debug statements. | |
debug | Provides standard debug output to console. | |
performance | Provides performance logging to console of internal method calls. | |
verbose | Provides extra debug output to console | |
namespace | Namespace used for DOM event and metadata namespacing. Allows module's destroy method to not affect other modules. | |
metadata | An object containing any metadata attributes used. | |
selectors | An object containing all selectors used in the module, these are usually children of the module. | |
classNames | An object containing all classnames used in the module. | |
errors | A javascript array of error statements used in the plugin. These may sometimes appear to the user, but most often appear in debug statements. |
Changing Settings
- A settings object can be passed in when initializing the plugin
$('.foo') .module({ moduleName: 'Godzilla', verbose: true }) ; - Default settings for the module can be overridden by modifying $.fn.module.settings.
$.fn.module.settings.moduleName = 'Godzilla';
- Settings can be changed after a module is initialized by calling the 'settings' method on the module with either a settings object or a name, value pair.
$('.foo') // lets initialize that! .module() // oh wait forgot something .module('setting', 'moduleName', 'Godzilla') ;
Reading Settings
Settings can also be read programmatically:
$('.foo').module('setting', 'moduleName');
// outputs godzilla