jQuery的UI选项卡加载事件不会触发

问题描述:

我有以下非常简单的代码:

I have got the following very simple code:

function init() {
    var articleTabs = $('#articleTabs');
    articleTabs.tabs('add',
            admin.pageVars.siteRoot + '/articles/themes/' + admin.pageVars.params.id, 'Temas');
    articleTabs.tabs({
        load : function(event, ui) {
            $('.jsonForm').jsonForm();
        }
    });
}

这成功将新的选项卡面板添加到现有的选项卡控件.但是,一旦激活,load函数就不会触发.

This successfully adds a new tab panel to an existing tab control. However upon activation, the load function does never fire.

我的错误是什么? (没有javascript例外)

What is my mistake? (There are no javascript exceptions)

请尝试以下操作,因为在创建标签页时您没有这样做:

Try this instead, since you're not doing it at the time of the tabs creation:

function init() {
  var articleTabs = $('#articleTabs');
  articleTabs.bind('tabsload', function() {
    $('.jsonForm').jsonForm();
  });
  articleTabs.tabs('add', admin.pageVars.siteRoot + '/articles/themes/' + admin.pageVars.params.id, 'Temas');
}

首先要确保它安全,但这会绑定到 tabsload事件代替load选项/处理程序,该选项/处理程序在初始窗口小部件创建后未设置.

This places it first to be safe, but this binds to the tabsload event instead of the load option/handler, which isn't set after initial widget creation.