Open and Close bootstrap modal using jquery?


I have a requirement to open and close bootstrap modal using jquery or javascript , as I have to kept it open until some background task is complete and after that close bootstrap modal pop-up as soon as task is completed succesffuly, how can iI achieve it using jquery-javascript?


Asked by:- pika
3
: 177 At:- 8/31/2017 11:20:42 AM
jQuery bootstrap modal-pop-up modal-dialog






2 Answers
profileImage Answered by:- jaiprakash

To close bootstrap modal you can use 'hide' as option to modal method as follow

$('#modal').modal('hide');

similarly, to open Modal pop-up using jquery, you can use

$('#modal').modal('show');

Or you can simply toggle the state of Modal pop-up using this Jquery Toggle

$('#modal').modal('toggle');
3
At:- 9/1/2017 7:17:42 AM
as I wanted, good answer 0
By : pika - at :- 9/4/2017 7:43:47 AM


profileImage Answered by:- vikas_jk

Bootstrap has a few functions that can be called manually on modals:

$('#myModal').modal('toggle');
$('#myModal').modal('show');
$('#myModal').modal('hide');

You can see more here: Bootstrap modal component

Sometimes jQuery get's conflicted due to some plugins which cause errors or we include jquery twice by mistake and above code doesn't work, in this case, add

jQuery.noConflict(); 
$('#myModal').modal('show');  // to show Modal pop-Up with Id 'myModal'
$('#myModal').modal('hide'); // to hide Modal pop-Up with Id 'myModal'
1
At:- 9/1/2017 8:09:20 AM Updated at:- 9/1/2017 8:09:44 AM





Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use

Subscribe Now

Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly