I have a web page that uses Bootstrap 3. In this page, I need to have a text area that a person can put their answer in. The answer is to a story problem. The story problem appears in a modal dialog. The setup can be seen in this Bootply. The code looks like this:
<div class="container">
<form>
<div class="form-group">
<label>Answer (<a id="showProblemLink" href="#">view problem</a>)</label>
<textarea class="form-control" rows="7"> </textarea>
</div>
</form>
<div id="problemModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<p>
The local school wants a new playground.
The lot they can use for the playground is shaped like a rectangle.
The school has decided to let the students design the new playground.
The students have decided that they want 1/4 of the playground to be a football field.
Another 3/8 of the lot will be used for a basketball court.
How much of the lot is remaining for the slides and swings?
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
My users want to be able to keep the story problem open in the modal window while they enter their answer. This will let them double-check their answer. The obvious answer is to have them re-open the dialog. But, apparently, this isn't good enough. I really need to keep the dialog open and let the user enter data in the text area behind/under it. Seems weird to me. But, that's what I gotta do.
My problem is, when I click on the textarea
, the dialog disappears. I tried adding data-backdrop="false"
. While that kept dialog open, it didn't let me actually edit the textarea
. What am I missing?
The backdrop option specifies whether the modal should have a dark overlay (the background color of the current page) or not.
To open a modal from another modal can be done simply by using the events that Bootstrap provides such as show. bs. modal . You may also want some CSS to handle the backdrop overlays.
The key idea is to have pointer-events: none; for the body when modal is open. But the specific elements you want to be interacted with should have e.g. pointer-events: auto; . In the example you can click both buttons when dialog is hidden, but only Toggle Dialog button when dialog is shown.
Example 1: First, we will design modal content for the sign-up then by using CSS we will align that modal centered(vertically). Using the vertical-align property, the vertical-align property sets the vertical alignment of an element.
Actually it is very simple to get exactly what you want.
What you are actually looking for is a Dialog and not a Modal.
Here is a working example using jQuery UI Dialog.
Explanation:
Here is a SO discussion about it
Some details about the example:
By default a dialog is draggable by the header. I kept the example similar to your modal so I took out the header by using:
dialogClass: 'dialog-modal'
And
.dialog-modal .ui-dialog-titlebar {
display:none;
}
To make the whole dialog draggable I used:
draggable: false
And
.parent().draggable();
If you actually do want a header, you can delete all these parts. Here is an example with a header
What you are trying to achieve is not easily possible.
I understand you want to save space on the page, that's why I would suggest the cleanest option and closest to what you are trying to achieve: Bootstrap Collapse
DEMO here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With