m0atz Posted May 30, 2013 Share Posted May 30, 2013 Hi all, I'm using a simple example template from Bootstrap and wish to display a modal form when the page loads. I have the code below direct from bootstrap to load the modal form when a button is pressed, but i've tried a few other things to get the modal to appear on load, but none of which is working. I'm sure its something simple, but this is a learning curve for me, so any help appreciated. Code I've got from Bootstrap: <!-- Button to trigger modal --><a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a> <!-- Modal --><div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3 id="myModalLabel">Modal header</h3> </div> <div class="modal-body"> <p>One fine body…</p> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> <button class="btn btn-primary">Save changes</button> </div></div> I've tried using the following to get it to load on the form load: $('#myModal').modal('show') and $(document).ready(function(){ $('#myModal').modal('show')}; neither of which I can seem to get to work. Cheers Col Link to comment Share on other sites More sharing options...
thescientist Posted May 30, 2013 Share Posted May 30, 2013 do you have any documentation for this? Are you sure you are implementing the toggle correctly? Are you checking for errors in the console? Biggest thing I see is you trying to reference by the id myModal, but you put that value as the href instead, not sure if that is consistent with the interface, but the documentation would clear that up. Link to comment Share on other sites More sharing options...
m0atz Posted May 30, 2013 Author Share Posted May 30, 2013 Hey thanks for the reply. I'm lifting the code straight from bootstraps examples : http://twitter.github.io/bootstrap/javascript.html#modals so shouldnt think its incorrect in terms of syntax. Using the button works cool, just when I try some kind of load... Link to comment Share on other sites More sharing options...
justsomeguy Posted May 30, 2013 Share Posted May 30, 2013 That should work, check your Javascript console for error messages. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now