Twitter Bootstrap Modal - IsShown

Hi, SO SO users,

You have this problem when I automatically populate a modal block.

Sometimes it already has content, so I tried to do hide / show for each request. But the show starts before the hide function is executed, so it breaks the script.

I can’t bind to the “hidden” one, because if this is the first time, it will not start the hidden function from the bootstrap.

Using modal ('true'), I see that the object has an isShown element, but does anyone know how I can access it?

The .log console shows this:

$backdrop [div.modal-backdrop] $element [div#modal-from-dom.modal] isShown true settings Object { backdrop="static", keyboard=true, show=false} hide function() show function() toggle function() __proto__ Object { toggle=function(), show=function(), hide=function()} 
+18
jquery twitter-bootstrap modal-dialog
Jan 6 2018-12-12T00:
source share
4 answers

Answer for Twitter Bootstrap 3:

 $("element").data()['bs.modal'].isShown 

or

 $("element").data('bs.modal').isShown 
+25
Oct 13 '13 at 7:24
source share

Answer:

 $("element").data('modal').isShown 
+10
Jan 10 '12 at 10:10
source share

In bootstrap 3.0.x

  $('#modal_Id').data().modal.isShown 

or

  $('#modal_Id').data('modal').isShown 

modal_id is the identifier of your modal

+3
Nov 23 '13 at
source share

If you want to use the Bootstrap solution of versions 2 and 3 and most likely you will not end up in data (since it looks like the name has already changed once) ...

$(element).hasClass('in') (will “fade” or “visible”, plus that it returns a boolean value)

or

"false" === $(element).attr('aria-hidden') (so that the aria is hidden or visible as well. "true" for hidden in this case.)

See the source from bootstrap 3.3.1 here :

 this.backdrop(function () { ... that.$element .addClass('in') .attr('aria-hidden', false) ... 

Again, this code is from 3.3.1. Can confirm this also works in 2.1.0. In this case, it is probably best to lose weight [sic].

+1
Jun 24 '14 at 19:12
source share



All Articles