Opened 6 years ago

Closed 6 years ago

#9252 closed feature (worksforme)

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.

Change History (1)

comment:1 Changed 6 years ago by Scott González

Resolution: worksforme
Status: newclosed

Problem is, what I'm doing isn't documented and probably I'm not supposed to do it.

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.

Note: See TracTickets for help on using tickets.