Search and Top Navigation
#9252 closed feature (worksforme)
Opened April 24, 2013 10:20PM UTC
Closed April 24, 2013 11:34PM UTC
Setting the widget's defaults
Reported by: | sga | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | none |
Component: | ui.tabs | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Hello,
Would you be interested in letting the user set the widget's default options for instances created in the future?
For example, I have a traditional PHP MVC web app and everywhere I use tabs, I want the ajax content to be loaded only on first click, not every time (the old "cache" option). There are about a hundred of template files, some of which have tabs and call .tabs() in different places.
At the moment, to achieve that, I use the following code right after including jqueryui.js in the <HEAD>.
$.ui.tabs.prototype.options.beforeLoad = function(event, ui) { if (ui.tab.data("loaded")) { event.preventDefault(); return; } ui.jqXHR.success(function() { ui.tab.data("loaded", true); }); }
The alternative would be to pass options at a 100 different places, which is a lot dirtier.
Problem is, what I'm doing isn't documented and probably I'm not supposed to do it.
Attachments (0)
Change History (1)
Changed April 24, 2013 11:34PM UTC by comment:1
resolution: | → worksforme |
---|---|
status: | new → closed |
That's actually exactly what you're supposed to do. If you'd like to see (better) documentation around this, feel free to send a pull request against https://github.com/jquery/api.jqueryui.com. If you don't have an idea for where to put this or what wording to use, you can just file an issue against that repo and we'll figure something out.
Thanks.