当标签深度嵌套在DOM中时,ajax窗口不起作用

时间:2012-02-29 21:03:21

标签: ajax jwindow

我正在使用深嵌套DOM打开ajax窗口。我在jquery中不是那么好,所以我试着在这里找到一些帮助。 jWindow应该在点击ajax-content时打开一个新窗口。 为了测试我把链接放在第一个DIV下面。这完美! 然后我添加了一些代码来生成一个TABLE,其中包含一个带有Number的coloum,其中包含SAME a-tag作为顶部的测试。这不起作用。

这是DOM的副本(我在两个a-tags周围放置水平规则,以便更容易找到它们):

 <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中的那个不想工作。

以下是Document ready的代码:

    $(".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 个答案:

答案 0 :(得分:-1)

你的问题是什么? rephrase plz。但如果我理解正确,你想循环throguh你的DOM中的所有元素 让我们说php让它看起来像     &lt; .div id ='foo'&gt;       &LT; .UL&GT;         &lt; .li&gt;&lt; .span id ='foo1'&gt;&lt; ./ span&gt;&lt; .span id ='foo2'&gt;&lt; ./ span&gt;&lt; ./ li&gt;         &LT;&。李GT;&LT; ./利&GT;         &LT;&。李GT;&LT; ./利&GT;       &LT; ./ UL&GT;     &LT; ./ DIV&GT;

并访问每个内部元素     $('#foo foo1')。click(function(){// handler in       $('#foo#foo1')。parent()。each(function(){//访问元素,返回li,循环遍历所有这些         $('#foo2',this).show(); //点击foo1,foo2将显示(作为示例)       });     },function(){//处理程序输出       $('#foo#foo1')。parent()。each(function(){         $( '#foo2的',这一点).hide();       });     }); 希望这有点帮助