Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

bootstrap modal popup disable click outside

 <button data-target="#myModal" data-toggle="modal" data-backdrop="static" data-keyboard="false">
    Launch demo modal
 </button>
Comment

bootstrap modal popup disable click outside

$('#myModal').modal({backdrop: 'static', keyboard: false})  
Comment

prevent bootstrap modal from closing when clicking outside

<div id="idModal" class="modal hide" data-backdrop="static" data-keyboard="false">
Comment

prevent close modal when click outside

$('#myModal').modal({
    backdrop: 'static',
    keyboard: false
})

or in HTML
<a data-controls-modal="your_div_id" data-backdrop="static" data-keyboard="false" href="#">
Comment

html close modal when click outside

<body>
  <div class="modal fade" id="modalID" tabindex="-1" data-bs-backdrop="true" style="border-radius:38px;">
    <div class="modal-dialog">
      <div class="modal-content">
	        Lorem ipsum ....
      </div>
    </div>
  </div>
</body>

<script>
  // Bootstrap 5
  let modal = new bootstrap.Modal( document.querySelector('#emailValidation'), { backdrop: true, keyboard: true } );
  modal.toggle();
</script>
Comment

when modal close event

$("yourid").on('hide.bs.modal', function(){
	// do it here
});
Comment

prevent modal from auto closing when clicked away

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
  Launch static backdrop modal
</button>

<!-- Modal -->
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Understood</button>
      </div>
    </div>
  </div>
</div>
Comment

prevent close modal when click outside

<div class="modal fade" id="myModal" data-keyboard="false" data-backdrop="static">
Comment

Stop modal from closing on outside click

Set the modal's backdrop to static. The modal component has a prop of backdrop, set that to backdrop="static"

<div>
    <Modal show={this.state.show} onHide={this.handleClose} backdrop="static">
        <Modal.Header>
            <Modal.Title>Change Password</Modal.Title>
        </Modal.Header>
        <Modal.Body>
            <form className="form-horizontal" style={{margin:0}}>
                <div className='password-heading'>This is the first time you have logged in.</div>
                <div className='password-heading'>Please set a new password for your account.</div>
                <br/>

                <label className="password">Password
                    <input type={this.state.type} className="password__input" onChange={this.passwordStrength}/>
                    <span className="password__show" onClick={this.showHide}>{this.state.type === 'input' ? 'Hide' : 'Show'}</span>
                    <span className="password__strength" data-score={this.state.score}>
                        <div className="strength_string">{this.state.strength}</div>
                    </span>
                </label>
                <br/>
                <label className="password">Confirm Password
                    <input type={this.state.type} className="password__input" onChange={this.passwordStrength}/>
                </label>

            </form>
            <br/>
        </Modal.Body>
        <Modal.Footer>
            <Button onClick={this.submitPassword} disabled={this.state.isDisabled}>Submit</Button>
        </Modal.Footer>
    </Modal>
</div>
Comment

click outside of the modal to close it

var images_modal = document.getElementById('images-model-div');

var videos_modal = document.getElementById('video-model-div');

// When the user clicks anywhere outside of the modal, close it

window.onclick = function(event) {

   if (event.target == images_modal) {

      images_modal.style.display = "none";

    }

    if (event.target == videos_modal) {

      videos_modal.style.display = "none";

    }

}
Comment

PREVIOUS NEXT
Code Example
Javascript :: react state not updating immediately 
Javascript :: leafletjs code 
Javascript :: es6 modules node 
Javascript :: Error capturing image. ionic 
Javascript :: import downloadcsv from "vue-json-csv"; 
Javascript :: mongoose connections 
Javascript :: column cannot be cast automatically to type bigint postgres sequelize 
Javascript :: jquery add event to dynamically created element 
Javascript :: this js 
Javascript :: js after settimeout 
Javascript :: jquery validation date min max 
Javascript :: react native ios assessibility font size 
Javascript :: error message to show in label jquery 
Javascript :: react-native-image-picker npm 
Javascript :: js compare tow object values 
Javascript :: persistent bugger javascript code 
Javascript :: import slider material ui 
Javascript :: str into array 
Javascript :: Get the Middle Character 
Javascript :: generate new component angular 
Javascript :: arguments object in javascript 
Javascript :: axios put request 
Javascript :: google maps load kml file javascript 
Javascript :: js date format 
Javascript :: react call bind apply 
Javascript :: import and export data in mongodb 
Javascript :: remove element array javascript 
Javascript :: js event handlers 
Javascript :: setstate 
Javascript :: async await react stackoverflow 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =