Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Closing a stacked modal via javascript


Hi!

I have a stacked modal on my page, and I want to close it by javascript.
I´m using the modal.hide() but nothing is happening. sad


<div class="modal fade" tabindex="-1" id="modal_stacked_nova_colecao"></div>


I initialized the stacked modal:

modalColecao = new bootstrap.Modal(document.querySelector("#modal_stacked_nova_colecao"));


And I´m trying to hide using:

modalColecao.hide(); // Hide modal	<pre lang="html">

</pre>

See the code here please:
<a>


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hello,
Really nice posting and very useful for Prestige Evergreen.
Thanks.



Hi,

Can you share your test URL so we can check it online and see the JS console?

Have you checked modalColecao variable before calling the hide method? Is it initialized and represents a valid Modal object?

Regards.



This might help you

https://devs.keenthemes.com/question/metronic-bootstrap-instance-is-undefined


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(