0

私のアプリは多くのモーダル フォーム ダイアログで動作します。関数を呼び出してモーダル フォーム ダイアログを作成したいのですが、ダイアログの [i.apply is not a function] で [OK] ボタンをクリックするとエラーが発生します。以下の私のコード

html:

<div id="dlg_srch_acnt">
        <table cellpadding="0" cellspacing="0" border="0" class="display" id="dtl_acnt_srch" style=" padding-bottom:0px;">
            <thead>
                <tr>
                    <th>Id</th>
                    <th>Account name</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>

脚本

function init_dlg(id, autoOpen, height, width, modal, fn_button1)
            {
                id.dialog({
                    autoOpen:autoOpen,
                    height:height,
                    width:width,
                    modal:modal,
                    buttons:{
                        'OK':fn_button1,
                    },
                    close:fn_close
                });
            }



function fn_ok()
            {
                $('#parnt_acnt').val(acnt_name);
                $('#dlg_srch_acnt').('close');
            }

init_dlg($('#dlg_srch_acnt'), false, '440', '480', true, 'fn_ok()');
4

4 に答える 4

3

私はあなた$('#dlg_srch_acnt').('close');がすべきだと信じています$('#dlg_srch_acnt').dialog('close');

そして、それが実行された値であるためではfn_okなく、引数に関数名を渡します。fn_ok()

init_dlg($('#dlg_srch_acnt'), false, '440', '480', true, 'fn_ok');

そしてacnt_name、あなたのfn_ok職務には何がありますか?(使用する前に)定義するか、変数名ではなく文字列を渡します。

于 2012-06-01T04:39:47.817 に答える
0

ボタンが1つしかないので、fn_button1の後のコンマを削除するのはどうでしょうか。

buttons:{
          'OK':fn_button1
        },
于 2012-06-01T04:39:59.923 に答える
0

$('#dlg_srch_acnt')jquery オブジェクトを関数に渡しているためです。したがって、このようにjqueryでIDをラップする必要があります

function init_dlg(id, autoOpen, height, width, modal, fn_button1)
            {
                $(id).dialog({ // Jquery wrapping should be done . 
                    autoOpen:autoOpen,
                    height:height,
                    width:width,
                    modal:modal,
                    buttons:{
                        'OK':fn_button1,
                    },
                    close:fn_close
                });
            }
于 2012-06-01T04:35:17.303 に答える