-2

Here I use a pop-up jQuery box for pop up window but when I use it on same page for multiple pop-up boxes then it only one not for all because my id is same on all button I use for pop-up.

<script src="js/jquery-1.9.1.js"></script>
    ;(function($) {

     // DOM Ready
    $(function() {

        // Binding a click event
        // From jQuery v.1.7.0 use .on() instead of .bind()
        $('#full-pop').bind('click', function(e) {

            // Prevents the default action to be triggered. 
            e.preventDefault();

            // Triggering bPopup when click event is fired
            $('#full-detail-box').bPopup();

        });

    });
})(jQuery);

and here is pop-up

<div id="full-detail-box">this is pop up</div>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Sam
  • 37
  • 3
  • 7

3 Answers3

1

Try This

JS

for(var i=0;i<3;i++){
    $('body').append("<div id='full-detail-box"+i+"' class='full-detail-box'>"+(i+1)+" User this is my pop-up window that is opem multi timewith different value </div><br/><a class='btn-pro' data-id='full-detail-box"+i+"' href='#'>Full Detail</a>")
}

 $('.btn-pro').bind('click', function(e) {


            e.preventDefault();

            var id=$(this).data('id');

            // Triggering bPopup when click event is fired
            $('#'+id).bPopup();

       });

Instead Of this

$('#full-pop').bind('click', function(e) {

            // Prevents the default action to be triggered. 
            e.preventDefault();

            // Triggering bPopup when click event is fired
            $('#full-detail-box').bPopup();

        });

UPDATED DEMO HERE

Kiranramchandran
  • 2,094
  • 16
  • 30
  • thanks dude but it it show same value for both button when i click 2 button it show 2nd user detail not show 1st user detail i use this for show user detail with pop-up – Sam Apr 08 '14 at 05:43
  • thanks a lot dude but can i automatic generate div here like full-detail-box, full-detail-box1, full-detail-box2, full-detail-box3, and many times – Sam Apr 08 '14 at 06:15
  • html added dynamically at document ready in a for loop $('body').append("
    "+(i+1)+" User this is my pop-up window that is opem multi timewith different value

    Full Detail")
    – Kiranramchandran Apr 08 '14 at 06:59
  • but it is show same detail for all user, i want show different detail with help of php – Sam Apr 09 '14 at 04:44
  • well i'm not an expert in php.. i just show you the sample javascript code to do this. you can append the content dynamically in the div by taking it from database. – Kiranramchandran Apr 09 '14 at 05:02
0

If I understand correctly you are passing the same id repeatedly, which just opens the same popup over and over again. If you want multiple popups you need multiple DOM nodes to trigger a popup on.

moliveira
  • 798
  • 8
  • 17
  • how i do this @moliveira – Sam Apr 08 '14 at 05:31
  • You could create the popup elements programmatically as Will Newton suggested above. I think something like $("
    this is pop up
    ").bPopup(); would work - but that is only one of many ways to accomplish that. The important part is that you are calling the popup function on different dom elements each time.
    – moliveira Apr 08 '14 at 05:44
0

If you are using user detail, why not just append a unique ID!? You can easily add, in PHP, or w/e the ID of the user at the end of the class name id="full-detail-box-xx" where XX is the ID of the user.

Then you simply use the button with the SAME id in the function to call the user, like $('#full-detail-' + id).click(function(){ bPopup('#full-detail-box' + id); });

If you are using PHP you can write the ID to a JS array, or something. I'm not sure how you system is set up.

WASasquatch
  • 1,044
  • 3
  • 11
  • 19