0

jquery UI ダイアログを作成した後にボタンを追加しようとしていますが、次のコードが機能しません。

私の要件は、ボタンのコンテンツを JSON の形式で動的に渡す必要があることです。そこで、jquery UI ダイアログを作成し、それにボタン コンテンツを追加しています。

以下にサンプルの JSON 構造を示します。

 "buttons": [{
                        "text": "button1",
                        "functionname": "test12",
                        "fncparam": { "param1": "testparam1", "param2": "1273576235" }
}]

 function dialog_box(dynDiv, rootTemplate) {
            var dialog_buttons = rootTemplate.buttons;
            var dialog = $("#" + dynDiv.id).dialog({
                hide: "explode",
                title: rootTemplate.etype,
                buttons: {},
                text: rootTemplate.text,
                resizable: true,
                minWidth: 200,
                minHeight: 150,
                close: function() {
                    $(dialog).dialog('destroy').remove();
                }
            });

            $('#dialog').dialog('option', 'buttons',
          [
                { text: 'New Button 01', click: function(ev, ui) { alert('New Button 01'); } }
                , { text: 'New Button 02', click: function(ev, ui) { alert('New Button 02'); } }

          ]);


        }

これで何が問題なのですか?Jquery UIダイアログを作成した後にボタンを追加する他の方法はありますか?

4

1 に答える 1

0

このようにボタンを作る

$("#" + dynDiv.id).dialog({
                hide: "explode",
                title: rootTemplate.etype,
                buttons: {},
                text: rootTemplate.text,
                resizable: true,
                minWidth: 200,
                minHeight: 150,
        buttons: [ 
        { text: "Close", 
        click: function() {
         $( this ).dialog( "close" );
         } 
    } ] 
    });
于 2013-10-05T04:33:36.047 に答える