2011-09-13 30 views
0

我需要一個叫做「test_var」變量傳遞給我的對話框 但我不知道該怎麼做傳遞變量到jQuery UI的對話框

如何傳遞變量從我的函數調用對話框到對話框?

//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 
}) 

,但它不工作

+0

你想用變量做什麼? –

+0

我想通過ajax把它發送到另一個頁面,但是我需要用戶評論和確認,這就是爲什麼我需要一個對話框 – max

+0

您是否需要將該變量用作對話框中顯示的一部分?變量來自哪裏? –

回答

2

只是使它成爲一個頂級變量,然後在對話框將不得不直接訪問它。