Skip to content

Instantly share code, notes, and snippets.

@reactormade
Last active October 12, 2015 14:08
Show Gist options
  • Save reactormade/4038377 to your computer and use it in GitHub Desktop.
Save reactormade/4038377 to your computer and use it in GitHub Desktop.
Twitter Bootstrap multiple remote modals on same page
anchor(base_url().'sample/'.$object->hash,'<span class="btn btn-mini btn-info"><i class="icon-search icon-white"></i> View</span>',array('data-remote'=>base_url().'sample/'.$object->hash,'data-toggle'=>'modal','data-target'=>'#modal-sample'));
$('#modal-sample').on('hidden', function() {
$(this).removeData('modal');
});
<div class="modal hide fade" id="modal-sample" tabindex="-1">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Sample</h3>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">Close</button>
</div>
</div>
@reactormade
Copy link
Author

"Second, the Modal plugin is designed to load the remote resource in the constructor of the Modal object, which unfortunately means that even if a change is made to the options.remote, it will never be reloaded.

A simple remedy is to destroy the Modal object before subsequent toggles. One option is to just destroy it after it finishes hiding"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment