Let's say I have the following link that's generated X times by a loop.
<a class="btn" data-toggle="modal" data-target="#view_more" href="/item/view/<?php echo $item_id; ?>">Launch Modal</a>
Here's the JS script that initiates the modal.
$(document).ready(function () {
$('#view_more').modal({
remote: '/item/view/1',
show:false
}); // Start the modal
It works when the remote
url is hardcoded, but I would like it to be dynamic depending on what gets passed to it.
The Modal plugin executes the load()
method in it's constructor, so really the only way to change the remote content of a Modal (other than manually doing the AJAX yourself) is to destroy it before doing another call:
$('#view_more')
.removeData('modal')
.modal({
remote: someURL,
show: false
});
There are more details in answer to a similar post: Twitter bootstrap remote modal shows same content everytime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With