0

I'm using Bootstrap and using this to show a modal after a click event:

$('#make_selects_modal').appendTo("body").modal('show');

I need to be able to execute a function (called pickClient) when this is shown. I tried something like this, but it doesn't work. Not sure of the correct syntax.

$('#make_selects_modal').appendTo("body").modal('show').pickClient();

2 Answers 2

4

When the modal is visible, an event called shown.bs.model is fired.

You can use

$('#make_selects_modal').on('shown.bs.modal', pickClient);

Modal event docs.

2

From the Bootstrap documentation you can use events for this, specifically in your case the shown.bs.modal event:

$('#make_selects_modal').on('shown.bs.modal', function () {
    pickClient();
})

Not the answer you're looking for? Browse other questions tagged or ask your own question.