I'm working on a dashboard that shows a list of hosts. When the user clicks on a host, I would like to pop up a modal dialog with additional details about that host. I'm currently using Bootstrap's remote modal functionality to trigger a Django view and populate the modal. This functionality is working just fine for the first modal that is generated. After that, the same modal is just shown every single time, regardless of the link that is clicked on.
I have found posts about this issue at SO and other places, and this is the proposed solution (using jQuery):
$('#hostDetail').on('hide.bs.modal', function(e) {
$(this).removeData('bs.modal');
});
I've tried doing this, but the above code never fires. I tried adding a console.log('hidden!') just to confirm, but the log never shows anything. No errors are showing in the console either. Is there some simple thing I've overlooking that is preventing this code from working? It's beginning to drive me crazy!
here is my html where I call the modal:
<a href="/portal/hostdetail/{{host.hostname}}" data-toggle="modal" host-name="{{host.hostname}}" data-target="#hostDetail">{{host.hostname}}</a>
and here is the modal itself (the local modal, not the remote one):
<div class="modal fade" id="hostDetail" tabindex="-1" role="dialog" aria-labelledby="remoteModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
Also, I have been reading that the 'remote' modal functionality is being deprecated from Bootstrap, and that I should use jQuery's .load function. If this is the case, and there's no way to fix my current code, can someone link me to a good resource to show exactly how to do it all through jQuery? I'm very much a noob when it comes to jQuery and Javascript, so something very basic would be awesome!
Thanks in advance.