I’ve been working with bootstrap and jQuery a little lately. While, it’s impressive what you can do just out of the box, it’s a little bit like the early days of javascript. There’s bootstrap, bootstrap-theme, and bootstrap-combined. Bootstrap’s own website says nothing of the “combined” version. Nobody explains what the “theme” version is for. A quick review of the docs fails to clarify that point.
While working up a basic website, I needed to have a modal dialog for user input. After googling a bit, I found this site: http://mode87.com/untame/demo/modalcontact/. The author uses the following these files:
- assets/bootstrap.min.css
- http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
- assets/bootstrap.min.js
So the author is clearly working with a downloaded version of the files and those files have either been modified or contain code that isn’t in bootstrap files anymore. The animation works great, the dialog slides in and out of the window.
When I use the same code to run the example on my local server and use bootstrap files from the CDN, it doesn’t work for me. That reminded me of early days of javascript where some javascript code would work on 9 browsers out of 10 but would fail on the 10th one just for sake of it. That was using the same browser. The same code would work even more unpredictably on different browsers. Javascript engines have come quite a ways from those times, but some of these bootstrap/jQuery frameworks haven’t quite caught up. Or if they have, the authors don’t seem to be communicating/documenting stuff properly enough.
In the end, this is how I solved the modal form fading in and out stuff.
<!-- this is how to show the dialog --> <span id="row-1" class="glyphicon glyphicon-arrow-down" style="margin: 2px 10px 2px 10px;" data-toggle="modal" data-target="#user-data"></span> <!-- this is the modal dialog --> <div id="user-data" class="modal fade"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"><button class="close" type="button" data-dismiss="modal">×</button> <h4 class="modal-title">User Settings</h4> </div> <div class="modal-body"> <div class="row"> What you want here. Form Inputs, Data displays, etc. </div> </div> <div class="modal-footer"><button class="btn btn-default" type="button" data-dismiss="modal">Close</button></div> </div> </div> </div>
You’ll need to add a <input type=”button”> tag and capture the onclick to respond to the OK hit and post back to the server or modify local UI elements.