0

I have created a modal window below to have customized buttons and functionality attached to those buttons using jQuery-UI. However, I want to do the equivalent in Bootstrap using JavaScript and not using data attributes. How would I do this? The Bootstrap website only gives the example of doing something like this using data attributes.

function showWindow(message) {
    windowShowing = true;
    $("#alertWindow").dialog(
    {
        height: 120, 
        modal: true, 
        buttons: 
        { 
          Continue: function(){$(this).dialog("close"); someProcedure();},            
          Exit: function(){$(this).dialog("close"); exitProcedure();}
        },
        close: function(){windowShowing = false;}       
     });
    $("#alertWindowMsg").text(message);
}

1 Answer 1

2

You can add separate handlers and use the modal methods provided by Bootstrap. Something like

$(".close-button").click(function(){
    $('#myModal').modal('hide');
    exitProcedure();
});

$(".continue-button").click(function(){
    $('#myModal').modal('hide');
    continueProcedure();
});
Sign up to request clarification or add additional context in comments.

2 Comments

Are you saying that I need to define these modal buttons in the HTML?
@FearlessFuture Yes, you can put those buttons inside the html of your modal and then add these handlers into your javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.