[問題] 關於jquery ui dialog傳值

看板Ajax作者 (嘿姆嘿姆)時間13年前 (2012/10/16 15:51), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
想問一下如果我在某一個page "A.html" 寫了一個button 如下面的code 點了之後可以跳出一個jquery的ui dialog...而這個dialog裡面的內容為B.html 如果我想在使用者填完資料後按下dialog的ok button之後, 可以得到在"B.html"裡面id為inputName的值,請問該怎麼取? (sorry,剛接觸jquery,問題可能很笨, 但我試了很多方法不是取不到值就是undefined) A.html ---- $(function(){ $('#name').click(function(){ var aaa = window.parent.$.dialog({ buttons: { 'ok': function(){ //取B.html的值(如id為inputName的值) aaa.dialog('close'); } } }); var link = 'B.html'; aaa.load(link); aaa.dialog('open') }); }); <div> <input type="button" value="input your name" id='name'> </div> ---- B.html ---- <input type="text" name="inputName" id="inputName"/> ---- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.220.253 ※ 編輯: heymuheymu 來自: 122.116.220.253 (10/16 19:53)

10/16 21:14, , 1F
$("#inputName").val()
10/16 21:14, 1F

10/16 21:24, , 2F
但我用上面的方法 在A取不到 B page的element
10/16 21:24, 2F

10/17 11:14, , 3F
在A多加一個隱藏的div~是可以接受的嗎?
10/17 11:14, 3F

10/17 11:14, , 4F
var aaa = $('#dialog').dialog ~測試過,這樣WORK
10/17 11:14, 4F
文章代碼(AID): #1GVH7yVa (Ajax)
文章代碼(AID): #1GVH7yVa (Ajax)