0

リモート コンテンツの読み込みに最適な jQuery タブ要素があります。

ただし、カスタム JavaScript を呼び出す「リセット」という別のボタンを追加したいと考えています。私は jQuery を初めて使用しますが、それが大好きで、これを行う方法がわかりません。

現時点でタブを作成している .js は次のとおりです。これは jQuery サイトのデフォルトです。

$(document).ready(function() {
$( "#tabs" ).tabs({
        ajaxOptions: {
            error: function( xhr, status, index, anchor ) {
                $( anchor.hash ).html(
                    "Couldn't load this tab. We'll try to fix this as soon as possible.");
            }
        }
    });
});

次に、私のPHPには次のものがあります。新しい「リセット」タブにカスタム アクションを追加したい。

<div id="tabs">
<ul>
    <li><a href="#map_canvas" title="content">Home</a></li>
    <li><a href="test.php" title="content">How this works?</a></li>
    <li><a href="test.php" title="content">View this at home</a></li>
    <li><a href="#reset" title="content">Reset</a></li>
</ul>

<div id="map_canvas">
</div>

</div>
4

1 に答える 1

2

タブselectには、コンストラクタ オプション オブジェクトに入れることができるイベントがあります。

$(document).ready(function() {
    $( "#tabs" ).tabs({
            ajaxOptions: {
                error: function( xhr, status, index, anchor ) {
                    $( anchor.hash ).html(
                        "Couldn't load this tab. We'll try to fix this as soon as possible.");
                }
            },
            select: function (event, ui) { // run this when a new tab is clicked
                if ($(ui.tab).attr('href') == "#reset") {
                    // Do stuff here
                }
            }
        });
});
于 2011-03-25T14:23:22.783 に答える