单击点击事件发生两次jquery点击事件

时间:2012-06-05 08:14:08

标签: javascript jquery event-handling

我使用了一个jquery点击功能,它的基本功能是,当我点击一个按钮时,一个div将会下降,然后在下一次点击时它会根据可见性检查返回。我为我的网页实施了分页,网页显示了搜索结果。每个搜索结果旁边都会显示该按钮。  当我点击第一页中的一组按钮时,它会正常工作,当我转到第二页时,它将会解决问题,而是打开然后关闭。  将在这里添加代码

$("#attachment").live("click", function() {
    attachmentRow = $(this).attr('class');
    //class value==att0 - 9 unique for each button
    attachmentRow = attachmentRow.replace('att', '');
    if (typeof results.hits.hits[attachmentRow]._source.Attachments != 'undefined') {
        if ($(".attDrop" + attachmentRow).is(':visible')) {
            $(".attDrop" + attachmentRow).empty();
            $(".attDrop" + attachmentRow).hide();
        } else {
            $(".attDrop" + attachmentRow).show();
            var attachmentRowLength1 = results.hits.hits[attachmentRow]._source.Attachments.Attachments.length;
            for (var j = 0; j < attachmentRowLength1; j++) {
                $(".attDrop" + attachmentRow).append("value");
            }
        }
    }
});

模板部分如下

<script id="srchTemplate" type="text/x-jquery-tmpl"> 
<div style="width: 700px; float:left; margin-bottom:15px;"><a href='${_source.HtmlRefName}' target='_new'>
<div id="Title">${_source.FilingCIK}</div><div id="Title">${_source.formType}</div></a>         
<div class="att${getNextname()}" id="attachment">Attachment Present</div></div>
<div style="width: 700px; float:left; margin-bottom:15px; padding-bottom:10px; border-bottom:1px solid #cccccc;">
<div id="formType">${_source.ParentformTypeCategory}</div><div id="date">Filing Date: ${_source.DateFiled}</div></div>
<div class="attDrop${DropgetNextName()}" id="realAttachment"></div>
</script> 

0 个答案:

没有答案