does not load my modal with bootstrap?

0

I have a table that loads me rows and each row has to show me a modal with a detail of the record of the row, it works correctly with the first row, but the other rows do not show me the modal

code:

<tr id="pedidoDetalle">
<td><?=$r["producto"]." "?><a href="#" id="detoxDet" id_detox="<?php echo $r['id_detox'] ?>" detox="<?php echo $r['idetox']; ?>" ><?php echo $verdetalle; ?></a></td>
    <td><?=$r["total"];?></td>
    <td><?=$r["cantidad"];?></td> 
  <td><?=number_format($r["total"] * $r["cantidad"],2);?></td>

java modal script:

<script>
$(document).ready(function(){  
  $('#detoxDet').click(function(){  
           var id = $(this).attr("detox"); 
           var id_detox = $(this).attr("id_detox");
           $.ajax({  
                url:"detalleDetox.php",  
                method:"post",  
                data:{id:id,id_detox:id_detox},  
                success:function(data){  
                    $('#detalle_detox1').html(data);  
                     $('#detalle_detox').modal("show");  
                }  
           });   
                  });  
 }); 
</script>

pdt: I think the problem is because the rows point to the same modal, in this case as I could do it please, regards

    
asked by ingswsm 21.11.2017 в 00:40
source

1 answer

0

By convention, the id of the elements must be unique, from what I see in the code, and one assumption of mine, the generation of the table would be in one cycle. What I would do at that point would be to change the jquery selector to a class selector and change the id by class in the element:

<a href="#" class="detoxDet" id_detox="<?php echo $r['id_detox'] ?>" detox="<?php echo $r['idetox']; ?>" ><?php echo $verdetalle; ?></a>

and in the selector:

//...
$('.detoxDet').click(function(){
     //tu codigo...
});
//...

I clarify that I have not verified all your code but it is the first thing I notice, and the other would depend on how you have your modal, since I do not see it in the supplied code.

Regarding the cycle, and what I mentioned about the unique id part:

<tr id="pedidoDetalle">

It would also be generating repeated ids. If I'm not right, it would be good to provide more details about your code.

    
answered by 21.11.2017 в 14:54