How to change `cache` and `ajaxOptions` when upgra

2019-08-13 13:40发布

Since I upgraded to jQuery UI 1.10 something has changed. Before that upgrade, code related to my jQuery UI Tab was the following:

$('.selector').tabs({
  cache: true,
  ajaxOptions: {
    dataType: 'html'
  }
 });

As wrote in the jQuery UI 1.10 Upgrade Guide, both cache and ajaxOptions has been removed. The guide also states to use the beforeLoad event, but how can I upgrade the code as well?

1条回答
一纸荒年 Trace。
2楼-- · 2019-08-13 13:59

A working approach is:

$(".selector").tabs({
    beforeLoad: function (event, ui) {
        if ( ui.tab.data( "loaded" ) ) {
          event.preventDefault();
          return;
        }
        ui.jqXHR.success(function() {
          ui.tab.data( "loaded", true );
        });
    }
});

Source: https://github.com/jquery/jqueryui.com/blob/master/page/upgrade-guide/1.9.md#deprecated-ajaxoptions-and-cache-options-added-beforeload-event

查看更多
登录 后发表回答