Every time modal open same file

I have a problem. I want my data dynamically view in modal. When I click first modal button its open dynamically and show data then when I click second button its show same previews data which opens first time. After reload the page when I click second its open dynamically again when I click first button its show second modal data.
Its WordPress site.

        <div class="modal booking-modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-body">
                         <?php
           foreach ($query as $row) 
                {   
                //var_dump($row);
                ?>


                        <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        </div>  
                        <div class="row"> 
                            <div class="col-md-12"> 
                                <div class="booking-modal-form">
                                    <form action="">
                                        <div class="form-group"> 
                                            <label>Check-in / Out</label>
                                            <input type="text" class="form-control datepicker" id="datepicker" name="datefilter" placeholder="Check-in / Out">

                                        </div>

                                        <div class="info-text">
                                            <?php echo $row->description ?>
                                        </div>

                                        <div class="book-it-btn">
                                            <button type="submit" class="btn btn-default">Apply</button>
                                        </div>
                                    </form>
                                </div>   
                            </div>
                        </div> 


                    <?php
                }
            ?>  

                    </div>
                </div>
            </div>
        </div>  

Jquery Modal data destroy code:

jQuery('body').on('hidden.bs.modal', '.modal', function () {
        jQuery(this).removeData('bs.modal');
      });

Read more here: Every time modal open same file

Leave a Reply

Your email address will not be published. Required fields are marked *