Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从ajax加载的jQueryUI选项卡中获取此方法_Javascript_Jquery_Ajax_Jquery Ui_Tabs - Fatal编程技术网

Javascript 如何从ajax加载的jQueryUI选项卡中获取此方法

Javascript 如何从ajax加载的jQueryUI选项卡中获取此方法,javascript,jquery,ajax,jquery-ui,tabs,Javascript,Jquery,Ajax,Jquery Ui,Tabs,我正在使用加载html,在该html中我有一个方法 $("#tabs").tabs({ beforeLoad: function (event, ui) { ui.jqXHR.error(function () { ui.panel.html( "Couldn't load this tab. W

我正在使用加载html,在该html中我有一个方法

$("#tabs").tabs({               
                beforeLoad: function (event, ui) {
                    ui.jqXHR.error(function () {
                        ui.panel.html(
                          "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                          "If this wouldn't be a demo.");
                    });
                    ui.jqXHR.success(function () {
                        alertMe()
                    });
                }
            });

<div id="tabs" style="height: 100%">
        <ul>
            <li><a href="Map.html">Tab 1</a></li>
        </ul>
 </div>
$(“#制表符”).tabs({
加载前:函数(事件、ui){
ui.jqXHR.error(函数(){
ui.panel.html(
“无法加载此选项卡。我们将尝试尽快修复此问题。”+
“如果这不是演示的话。”);
});
ui.jqXHR.success(函数(){
alertMe()
});
}
});

在map.html中,我有alertMe方法。在这里,它表明alertMe是未定义的。

当服务器成功返回响应时,但在任何选项卡呈现逻辑发生之前(如将html/js添加到页面),调用jqXHR“success”。因此,更好的解决方案是使用tabs控件的load方法来处理调用:

$('tab's).tabs({
    beforeLoad: ...
    load: function() {
       alertMe(); // Global JS on loaded fragment will be available on page now
    }
});
API文档: