How to change `cache` and `ajaxOptions` when upgrading to jQuery UI 1.10?

烈酒焚心 提交于 2019-12-13 02:54:41

问题


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:


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



来源:https://stackoverflow.com/questions/16856795/how-to-change-cache-and-ajaxoptions-when-upgrading-to-jquery-ui-1-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!