Archive for February, 2017

Give focus to a control in a Bootstrap modal popup window

The times that try men’s’ souls is when you have a Bootstrap modal popup window, and you can’t get the control you want to get focus. So if I have a modal popup window like so:

<div id=”resultsModal” class=”modal fade” role=”dialog”>
   <div class=”modal-dialog”>
      <div class=”modal-content”>
         <div class=”modal-header”>
            <button id=”modalClose” type=”button” class=”close” data-dismiss=”modal”>&times;</button>
            <h4 class=”modal-title text-center”>Update Record</h4>

         <div class=”modal-body”>
            <div class=”form-inline” style=”margin-left: auto; margin-right: auto; width: 400px”>
               <div class=”form-group”>
                  <label for=”theDate” >Date: </label>
                  <input type=”text” id=”theDate” class=”form-control” /><br>
                  <input type=”button” id=”save” value=”Save” onclick=”saveRecord() class=”form-control saveButton” />

         <div class=”modal-footer”>
            <button type=”button” class=”btn btn-default” data-dismiss=”modal”>Cancel</button>

To give focus to the date textbox, I use this little snippet:

$(“#myModal”).on(“”, function () {


Leave a comment

Expand a DIV width beyond its parent

I had an issue where a content management system restricted the layout of the page to have three columns. I wanted the results of a search, which were displayed in a div tag, to expand to fill (almost) the entire width of the screen. After just a bit of tweaking with padding and width, I ended with this:

<div id=”results” style=”margin-left: calc(-50vw + 50%);padding-left: 15px; width: 98vw; “></div>

Note that your mileage may vary. This particular code worked with the arrangements of elements in my page, and I have not tested it thoroughly enough to say it would work in all instances.

Leave a comment