Loading dynamic URLs through modal

Let's say I have the following link that generates X times in 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 URL is remotehard-coded, but I would like it to be dynamic depending on what is passed to it.

+5
source share
1 answer

The Modal plugin executes the constructor in it load(), therefore, in fact, the only way to modify the remote Modal content (with the exception of manually executing AJAX yourself) is to destroy it before making another call:

$('#view_more')
  .removeData('modal')
  .modal({
    remote: someURL,
    show: false
  });

: Twitter bootstrap remote modal

+9

All Articles