0

我正在为在深层嵌套 DOM 中打开一个 ajax 窗口而苦苦挣扎。我在 jquery 中不是那么好,所以我尝试在这里找到一些帮助。jWindow 应该在点击 ajax-content 时打开一个新窗口。为了测试,我在第一个 DIV 下放了一个链接。这很完美!然后我添加了一些代码来生成一个表,其中包含一个带有数字的列,其中包含与顶部测试相同的 a-tag。这不起作用。

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

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

但是我找到了这个类的所有(顶部样本和嵌套的)标签。所以,我完全迷失和绝望。不知道为什么这些嵌套链接不起作用。

如果有人有解决方案,我会非常感激。

非常感谢,乔

4

1 回答 1

-1

你的问题是什么?请改写。但如果我理解正确,你想循环遍历 DOM 中的所有元素,可以说 php 使它看起来像 <.div id='foo'> <.ul> <.li><.span id='foo1' ><./span><.span id='foo2'><./span><./li> <.li><./li> <.li><./li> <./ul> <. /div>

并访问每个内部元素 $('#foo foo1').click(function(){// handler in $('#foo #foo1').parent().each(function(){//访问元素,返回 li,循环遍历所有元素 $('#foo2',this).show();// 点击 foo1,会显示 foo2(例如) }); },function() {// handler out $('#foo #foo1').parent().each(function(){ $('#foo2',this).hide(); }); }); 希望这有所帮助

于 2012-02-29T21:18:29.233 回答