将变量传递给jQuery ui对话框

时间:2011-09-13 13:40:00

标签: javascript jquery jquery-ui

我需要将一个名为'test_var'的变量传递给我的对话框 但我不知道该怎么做

如何将调用对话框的函数中的变量传递给对话框?

    //a tag calls to starter function and sends variable as parameter

        <a href="#" onclick="starter(test_var)"> go </a>
    //starter func recives the test_var and calls the dialog box 
//what i want is to somehow send test_var to dialogbox in here


            function starter(test_var){

           //some stuff 

            $('#dialog_div').dialog('open');
            return false;
            }
            }


            $('#dialog_div').dialog({
            aoutoOpen:false,
            with:600,
            buttons:{
            "ok":function(){

    // i want to be able to alert test_var in here 
            alert(test_var)
            }
            }
            })

        }

我试过

function starter(test_var){

       //some stuff 

        $('#dialog_div').dialog('open' , test_Val);
        return false;
        }
and

$('#dialog_div').dialog(test_val , {//coode
})

但它不起作用

1 个答案:

答案 0 :(得分:2)

只需将其设为顶级变量,然后对话框即可直接访问它。

相关问题