1

I want to call modal("hide") in a 'silent' way - i.e. not to trigger the event handlers which I attached using .on("hidden.bs.modal"). How?

Noam Hacker
  • 3,845
  • 7
  • 30
  • 52
user3599803
  • 4,641
  • 10
  • 50
  • 95

2 Answers2

1

Maybe you could use a var isSilent inside your on hide event and have an if silent do nothing else do stuff, rather than trying to unbind events.

0

I would unbind the event handler, hide the modal, and then re-bind the event handler. See this question for the best ways to remove an event handler.

The answer demonstrates using the jquery off() function like so:

$('#myimage').on('click.mynamespace', function() { /* Do stuff */ });
$('#myimage').off('click.mynamespace');


Alternative:

Temporarily override your trigger somewhere in your code, and then remove that piece of code when you are done:

.on("hidden.bs.modal") { //do nothing }

Community
  • 1
  • 1
Noam Hacker
  • 3,845
  • 7
  • 30
  • 52