2012-02-29 53 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