Reputation: 2036
I often see developers add methods to their own jquery Widget by extending the widget object. I'm not certain I really understand why and would appreciate if somebody could explain.
For example, the author(s) of jQuery UI Autocomplete Widget add 2 methods to their widget, why didn't they just have it in the original widget object?
Upvotes: 3
Views: 162
Reputation: 780724
These utility functions don't access any of the widget's internal data, so they don't need to be within the widget function. The names are put into the widget's namespace to prevent polluting the global namespace.
Upvotes: 1