4

jquery ui ダイアログ ボックスで定義されたカスタム ボタンがあります。

$("#myDlg").dialog({
        modal: true,
        buttons: {
            'My Custom Link': function () {
                alert('my custom message');
            },
            'Close': function () {
                $(this).dialog('close');
            }
        }
    });

ボタン 'My Custom Link' をデフォルトのボタン スタイルではなく、html リンクとして表示したいと思います。どうやってやるの?ありがとう。

4

1 に答える 1

6

デフォルトのjQueryオプションはリンクの追加をサポートしていません..しかし、あなたが望むものをラッパーに追加することができます..以下を参照してください.

$(function() {
    $("#myDlg").dialog({
        modal: true,
        buttons: {
            'Close': function() {
                $(this).dialog('close');
            }
        }
    })
    .parent()
    .find('.ui-dialog-buttonset')
    .prepend('<a href="javascript:void(0);" id="myCustomLink">My Custom Link</a>');

    $('#myCustomLink').click(function () {
        alert('my custom message');
    });
});

デモ

于 2012-05-21T21:24:14.387 に答える