Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder Mooseman's Avatar
    Join Date
    Sep 2010
    Posts
    123
    Thanks
    7
    Thanked 3 Times in 3 Posts

    [Twitter Bootstrap] Options can't be changed after opening the modal

    I am initializing the modal:

    Code:
    $("#modal").modal({keyboard: true, backdrop: true});
    And attempting the change the options from the console:

    Code:
    $("#modal").data('modal').options.keyboard = false;
    $("#modal").data('modal').options.backdrop = 'static';
    However, clicking the backdrop or hitting the Esc key still causes the modal to be hidden. How can I effectively unbind the keypress and click events? Thank you.

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    well without telling us what script you are using for .modal() we really cannot help. I would venture to guess that you need to change the options the same way you set them, unless your script specifies otherwise.

  • #3
    Regular Coder Mooseman's Avatar
    Join Date
    Sep 2010
    Posts
    123
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by DanInMa View Post
    well without telling us what script you are using for .modal() we really cannot help. I would venture to guess that you need to change the options the same way you set them, unless your script specifies otherwise.
    I'm using the Twitter Bootstrap modal found here. There is no documentation on changing the options after the modal is called.

  • #4
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    ahh ok, I would venture a guess tha tyou need to change the options using the same method you used to initialize the modal.

  • #5
    Regular Coder Mooseman's Avatar
    Join Date
    Sep 2010
    Posts
    123
    Thanks
    7
    Thanked 3 Times in 3 Posts
    I re-initialized the modal with this:

    Code:
    $("#modal").modal({keyboard: false, backdrop: 'static'});
    However, there is no visible effect generated whatsoever. Any other ideas? Thanks!

  • #6
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,312
    Thanks
    23
    Thanked 612 Times in 611 Posts
    @Mooseman, What do you want to happen and why? Could it be done a different way? Could you put a different modal up with your info that meets you criteria?
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #7
    Regular Coder Mooseman's Avatar
    Join Date
    Sep 2010
    Posts
    123
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by sunfighter View Post
    @Mooseman, What do you want to happen and why? Could it be done a different way? Could you put a different modal up with your info that meets you criteria?
    According to the documentation here, the setting backdrop can be true or 'static', If it is true, clicking the backdrop will hide the modal, if 'static', clicking the backdrop will not have any effect. For the setting keyboard, it's either true or false if you want the modal to be hidden when the esc key is pressed.

    I am using the modal to show a form and I need to to remove the user's ability to hide it from the page while the ajax call is out. Since I'm already using this across other pages, I'd prefer not to change it.

    I think the problem is that the backdrop and esc key functions are already bound, but I'm not sure how to unbind them here.

  • #8
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,312
    Thanks
    23
    Thanked 612 Times in 611 Posts
    An old trick to keep people from copying images was to display a bare translucent image with high z-index over the page so they never click on the page, just the image. Didn't work cause you could turn JS off and get them, but I think this would work for you.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #9
    Regular Coder Mooseman's Avatar
    Join Date
    Sep 2010
    Posts
    123
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Thanks for your help. I ended up editing the script to namespace the click events so I could use .on/.off.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •