jquery没有使用分页

时间:2014-02-27 07:57:45

标签: php jquery

我只是想在分页中显示所有列表。我在我的文件上使用datatable插件的分页,分页工作正常,在列表中我有一个图像,点击功能删除。在我的分页中,显示了五个记录。点击下一步显示的其他五个记录,当我点击下一个删除功能时,删除功能在第一个五个记录上正常工作停止它正在工作。 我的代码: -

<script>
var conf = jQuery.noConflict();
conf(document).ready(function(){
 conf(".delete").on( "click", function() {
alert('adfasdfasd');
    //alert(conf(this).attr("id"));
custid  = conf(this).attr("id");

var r=confirm("Are you sure");
if (r==true)
  {

        var url = "<?php echo Mage::getBaseUrl();?>turnkey/index/deleteuser/";
            conf.ajax({
            type:"POST",
            url:url,
            data: { 'custid':custid},
            success: function(msz){
            alert(msz);
            if(msz=="deleted") {
            conf("#hidepro"+custid).hide("slow"); 
            }
            else {
                //conf("#hidepro"+proid).hide();
            alert("product cant be deleted");
            }
            //console.log("chal hun");
            }
        });
  }
else
  {
 return false ;
  }


  });
});



</script>

,分页代码为: -

    <script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
                $('#example').dataTable();
            } );
    </script>

<div id="container">


<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
    <thead>
        <tr>
            <th>Factory</th>
                <th></th>
            <th>Contact</th>
            <th>URL</th>
            <th>Remove</th>

        </tr>
    </thead>
    <tbody>

<?php 
foreach( $custemail as $custemail1 ) { 
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($custemail1); //load customer by email id ?>


        <tr class="odd gradeX" style="  border-bottom: 1px solid #FF0000;" id = "hidepro<?php echo $customer['entity_id'] ?>">
            <td class="bodyText style4" ><a style=" color: #CC3300;float: left;margin-top: 42px !important;text-decoration: underline;" href="<?php echo Mage::getBaseUrl();?>turnkey/index/listuser?id=<?php echo $customer->getEntity_id();?>"><?php echo $customer->getFactory();?></a>   </td>

        <td class="bodyText style4">
<a href="<?php echo Mage::getBaseUrl();?>turnkey/index/listuser?id=<?php echo $customer->getEntity_id();?>">
<img style=" width:100px;height:100px;margin-bottom:5px ;" src = "http://lab.ghrix.com/turn-key-mart/media/<?php echo $customer->getUserImage();?>"></a>

</td>
            <td class="bodyText style4" style="padding-top: 10px;">
<?php echo $customer->getFirstname();?><?php //echo $customer->getUser_address();?><br><?php echo $customer->getmobile();?><br><?php echo $customer->getEmail();?></td>

            <td class="bodyText style4" style="float: left;margin-top: 42px !important;" >

<a target="_blank" style="color:#005580;" href="<?php echo $customer->getWebsite();?>"><?php echo $customer->getWebsite();?></a></td>

            <td class="bodyText style4"><div  style= "cursor:pointer;" class = "delete" id  = "<?php echo $customer['entity_id'] ?>"><img width="60px" src="<?php echo $this->getSkinUrl('images/trash.jpg'); ?>"</div></td>

        </tr>


<?php }?>   

    </tbody>
</table>
            </div>      


        </div>

请说明错误发生的地方。

1 个答案:

答案 0 :(得分:2)

没有实例,我不能确定,但​​试试这个:

替换

conf(".delete").on("click", function() ...

使用:

conf(document).on("click", ".delete", function() ...

原因是conf(“。delete”)仅附加到运行该函数时可用的元素。可能是您的dataTable插件首先运行,删除了额外的元素,然后运行删除绑定器并且仅在前5个工作。第二个方法绑定到文档,并检查每次单击以查看它是否与.delete选择器匹配。这曾经被称为jQuery.live()