Tuesday, 28 August 2012

Using Twitter Bootstrap's modal from an ajax loaded page.

So I'm working on one of my apps and had an issue with modal dialogs and Bootstrap. According to Bootstrap, you can do something like this:
Activate a modal without writing JavaScript. Set data-toggle="modal" on a controller element, like a button, along with a data-target="#foo" or href="#foo" to target a specific modal to toggle. 
Therefore, initially, this is what I had:

 <a data-toggle="modal" href="#help-with-url" >Content not showing up?</a>

However, what I found was that on pages that are loaded via ajax which the contents are put on a separate dialog, one cannot use what they described above for reasons I do not know why. I checked to see if there were any errors in the bootstrap js, but couldn't find any. I did solve it by just calling the modal using the javascript way, like so:

 <a onclick="$('#help-with-url').modal()" data-toggle="modal" >Content not showing up?</a>





No comments:

Post a Comment