open the JQuery dialog by the div idAsk Question


I want to open a dialog for each product I have in my database.

But how can I open a dialog for all these div ID's I've in my database without hard coding it?

It looks like this: Website How can I get these information in the correct dialog

Dialog that needs to open:

                            <?php foreach($hotels as $key => $hotel)    {
                                <div class="click_div" id="<?php echo  
                                <?php echo $hotel['MaasduinNaam']; ?>


            <?php   } ?>

JQuery / PHP

                            foreach($hotels as $key => $hotel)
                    <?php if ($hotel['MaasduinCategory'] == 'Appartementen'): ?>

                            <div class="products-<?php echo $hotel['MaasduinId'];?>">
                                <div class="maasduin-foto"><img style="width: 136px; height: 134px;" src="\Maasduinen-NW\image\<?php echo $hotel['MaasduinImage']; ?>">
                                    <?php if ($hotel['MaasduinPas'] == '1'): ?>
                                        <div class="maasduin-actiefoto">
                                            <img style="width: 40px; height: 40px;" src="\Maasduinen-NW\image\<?php echo $hotel['MaasduinPasfoto']; ?>">
                                    <?php endif ?>
                                <div class="maasduin-naam"><?php echo $hotel['MaasduinNaam']; ?></h3></div>
                                <div class="maasduin-locatie"><?php echo $hotel['MaasduinLocatie']; ?></div>
                                <div class="maasduin-email"><?php echo $hotel['MaasduinEmail']; ?></div>
                                <div class="maasduin-telefoon"><?php echo $hotel['MaasduinTelefoon']; ?></div>
                                <div class="maasduin-website"><?php echo $hotel['MaasduinWebsite']; ?></div>

                  var $dialog; 
                        $(document).ready(function () {

                              // $(this).attr('id') will return the id
                              $dialog = $(this).attr('id');

                            $("div[class^='products-']").click(function () {
                                return false; ////cancel eventbubbeling

                        function showDialog() {
                            return false //cancel eventbubbeling


I hope someone can help me solve this problem.

标签: jquery
© 2014 TuiCode, Inc.