1
I believe it’s a matter of putting the code in the right place, but I’m racking my brain and I can’t...
I made a test with the standard Bootstrap code, where it works on a button. I even put the data calls inside it and it worked.
The question now is, does my index return database values by while:
while ($posts = mysql_fetch_array($busca)){
extract($posts);
?>
<div class="col-md-2" >
<div class="item-title">
<h6 class="title">
<strong>
<a href="single.php?id=<?php echo $posts['id']?>" title="<?php echo $posts['titulo']; ?>" >
<?php echo $posts['titulo']; ?></a>
<strong>
</h6>
</div><!--Fecha titulo do posts/item-->
<div class="item-img" data-toggle="modal" data-target=".bs-example-modal-lg">
<a href="single.php?id=<?php echo $posts['id']?>" title="<?php echo $posts['titulo']; ?>" class="thumbnail">
<img src="uploads/<?php echo $posts['path'] ?>" title="<?php echo $posts['titulo']; ?>" alt="" id="blc-img" />
</a>
</div><!--Fecha Imagem do posts/item-->
<div class="item-vist">
<h6 class="vist"><small>Visitas <b><?php echo $posts['visitas'] ?></small></b></h6>
</div><!--Fecha Visitas do posts/item-->
</div>
<?php
};
?>
How can I adapt this code so that when clicking on one of the items, it opens in Modal, and not in single.php? like this at the moment.
Modal code:`
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button>
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg">
<div class="modal-content">
...
</div>
</div>
</div>`
I will not modify the standard Modal code (I believe there is no need). I would like to click on one of the returned items, open in Modal.
My idea is when you click on the post (the one below Catalogo), it opens the same way as the button.
Thank you in advance!
Place the modal and the button that will call the modal inside the while and the respective bank retornor in each position.
– RFL
@Rafaelacioly sorry, could you be a little more specific? in case I do not want to use the button to call the modal, and yes the own post as call to the modal...
– Henrique Silva
you want when the bank query is performed the modal already appears?
– RFL
@Rafaelacioly put a print of the modal with button. The ideal is to work when you click on the post (the cover that is below the word Catalogo)
– Henrique Silva
@Henriquesilva, the Boostrap modal does not allow you to run multiple modals, so it is not loading the content you want, but you can create separate blocks and call them within a single modal, take a look at my answer: http://answall.com/questions/81050/como-usar-multiplas-modals-no-bootstrap/81095#81095
– Ivan Ferrer
That picture in the catalog reminded me of Sephiroth in Final Fantasy VII
– SneepS NinjA
@Ivanferrer sorry, I don’t think I understand...in the logic of php, this would not be a single modal?
– Henrique Silva
Yes, it is correct true, I had not noticed, but you have to send an id to each element of your loop to be loaded inside your modal, otherwise it will always carry only the first external div element of your modal. Look at this example: http://jsfiddle.net/Lyp615jw/5/
– Ivan Ferrer
@Ivanferrer ! Thank you for your help. I was able to adapt your reference perfectly... I’m only with a small problem, when I click off the Modal it closes and the index page shrinks a little the right side, and if I keep entering other Modals and clicking outside it will shrink more... You know what it can be?
– Henrique Silva