2012-02-29 22 views
0

我正在用深度嵌套的DOM打開ajax窗口。我在jQuery中並不擅長,所以我嘗試在這裏找到一些幫助。 jWindow應該用ajax-content點擊打開一個新窗口。 爲了測試我把鏈接放在第一個DIV下面。這工作完美! 然後,我添加了一些代碼來生成一個表,其中包含一個包含一個數字的coloum,其中包含相同的a-tag作爲頂部的測試。這不起作用。當標籤深深地嵌套在DOM中時,ajax窗口不起作用

這裏是DOM的複印件(我把周圍的兩個標籤水平規則,以使其更容易找到他們):

<div id="content"> 
<p> 

<a class="get_detail_bill_window" bnr="177" shop="2" href="#">Text Ajax</a> 

</p> 
<div id="form_selection"> 
<div class="ui-widget ui-widget-content ui-corner-all" style="padding: 5px; font-size: 1em; width: 1200px;"> 
<div class="t_fixed_header_main_wrapper ui-widget ui-widget-header ui ui-corner-all"> 
<div class="t_fixed_header_caption ui-widget-header ui-corner-top"> 
<div class="t_fixed_header_main_wrapper_child"> 
<div class="t_fixed_header ui-state-default ui" style="border: medium none; font-weight: normal;"> 
<div class="headtable ui-state-default" style="margin-right: 15px;"> 
<div class="body ui-widget-content" style="height: 340px; overflow-y: scroll;"> 
<div> 
<table id="atcs_sort" style="width: 1182px;"> 
<colgroup> 
<tbody> 
<tr> 
<td class="ui-widget-content">2011-10-16</td> 
<td class="numeric ui-widget-content"> 

<a class="get_detail_bill_window" bnr="341" shop="2" href="#">341</a> 

</td> 
<td class="numeric ui-widget-content">02:25:08</td> 
<td class="numeric ui-widget-content">2011-10-16</td> 

如果你看看這兩個錨點,它們是絕對相同的。但嵌套在DOM中的那個不想工作。

這裏是文檔的準備代碼:

$(".get_detail_bill_window").on({ 
click: function() { 
    var shop=$(this).attr('shop'); 
    var bnr=$(this).attr('bnr'); 
    alert("bin im Click - Shop: "+shop+" Billnr: "+bnr); 

var a = $.jWindow 
({ 
    id: 'detail_bill', 
    title: 'Details of Bill-Nr.: '+bnr, 
    minimiseButton: false, 
    maximiseButton: false, 
    modal: true, 
    posx: 450, 
    posy: 50, 
    width: 700, 
    height: 200, 
    type: 'ajax', 
    url: 'sge_detail_bill.php?s='+shop+'&bnr='+bnr 
}).show(); 


    a.update(); 
} 
}); 

我嘗試這樣看,如果選擇可能有問題:

var pars = $(".get_detail_bill_window"); 
for(i=0; i<pars.length; i++){ 
    alert("Found paragraph: " + pars[i].innerHTML); 
} 

但我發現所有(頂部樣品和嵌套的)與這個類的a-tags。 所以,我完全失去了和絕望。不知道爲什麼這些嵌套的鏈接不工作。

如果有人有解決方案,我會非常感激。

許多在此先感謝, 喬

回答

-1

你的問題是把短?重述plz。但如果我理解正確的話,你要循環throguh DOM中的 所有元素可以說PHP使它看起來像 < .div ID =「富」> < .UL> <。李> < .span ID = 'foo1'> < ./span> < .span ID = 'foo2的'> < ./span> < ./li> <。李> < ./li> <。李> < ./li> < ./ul> < ./div>

and acce每個內部元素都做 $('#foo foo1')。click(function(){//處理函數在 $('#foo#foo1')。parent()。each(function(){//訪問元素,返回li,循環遍歷所有元素 $('#foo2',this).show(); //點擊foo1時,foo2將顯示(作爲示例) }); ()函數(){//處理函數出來 $('#foo#foo1')。parent()。each(function(){('#foo2',this)。隱藏(); }); }); 希望這有些幫助

+0

你好Semur,非常感謝你的時間。但是,不,我不想循環。該表已經在DOM中,並且在每一行中都有適當的鏈接。我只想要,如果我在這個色彩中連續點擊這個墨水,打開ajax-content的窗口。就像這個嵌套結構外部的鏈接一樣,它完美的工作。請看我上面描述的2個a-tags,它們絕對是相似的,只是其中一個(不工作)深深地嵌套在表格的td-tag中。 – JSS 2012-02-29 21:36:50