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?
            Asked
            
        
        
            Active
            
        
            Viewed 232 times
        
    1
            
            
         
    
    
        Noam Hacker
        
- 4,671
- 7
- 34
- 55
 
    
    
        user3599803
        
- 6,435
- 17
- 69
- 130
- 
                    pls show us your code – Iceman Aug 15 '16 at 20:48
2 Answers
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.
 
    
    
        techimperial
        
- 31
- 2
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
        
- 4,671
- 7
- 34
- 55
- 
                    Is there a better way? I prefer not to store my handlers in vars just to bind them again – user3599803 Aug 15 '16 at 21:06
- 
                    @user3599803 I have updated my answer with an alternative, let me know if it helps. – Noam Hacker Aug 16 '16 at 00:36
- 
                    you could put script tags in a `div` letting the id="script_div". then use jquery to append or remove the `div` – Noam Hacker Aug 16 '16 at 17:25