The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery, Bootstrap help ?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #37842


    I am trying to use

    but it loads on “page load” as it seems

    I would like to toogle it by clicking on the Launch Modal button
    kinda lost here


    What button are you wanting to trigger this event?


    First of all you need to give you toggle button an id. This way you can better locate this element and apply events to its object. Like so:

    ​Launch Modal​

    Now we can easily target this element. You can make the argument that we don’t need an id to target this element but it is A LOT simpler and faster to do it this way. Now that we can get ahold of this object we need to apply the toggle to its “click” function. JQuery makes this easy for us:

    $(document).ready(function() {
    $('#modalTrigger').on("click", function(){

    In the code before, the event to toggle that element we handled immediately after the document was ready. What you want is to assign this click event to your element immediately after the document is ready. And inside that click event, you want your toggling action.

    Does that help?


    That is because you are not hiding that modal window with CSS first.

    You can do this with CSS or JavaScript


    #myModal {


    //inside your $(document).ready() function

    It is better practice and inline with the ideal MVC model to keep your style (including hiding this modal window) in your CSS.


    Good to hear. No problem.


    I stumbled across this problem a little while ago and used the settings of the model box (which is better than “messing” with it). Use one of those settings:

    show: false, // Set to false, otherwise the model will show up while loading the page
    keyboard: true, // Set to true, now the window can be closed with the keyboard
    backdrop: true // Set to true for creating a "black" background
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.