miner
miner

Reputation: 305

How to destroy a twitter bootstrap modal with a carousel in it?

I have a carousel within a modal and I am trying to "reset" it when the user click on the dismiss-button.

In the carousel, the user will do some click actions that will change the images in the carousel. The functionality that I am trying to achieve is that when the user clicks dismiss and then clicks on the toggle-modal-button, all the original elements in the carousel are restored and that the carousel starts at slide 1.

I have looked at other posts suggesting to use this function, but it does not give the desired effect for me:

$("#myModal").on('hidden.bs.modal', function () {
    $(this).data('bs.modal', null);
});

I am not posting any code here, I would just really like some input on how to attack this problem. In addition to destroying the modal itself, is there perhaps an additional function that resets a carousel? Or is the approach to reset each element that has changed in the carousel "manually" in my function?

Have a nice evening.

Upvotes: 0

Views: 1742

Answers (1)

Tim Williams
Tim Williams

Reputation: 318

If you are using the standard bootstrap carousel you can change it to any index.

$("#myModal").on('hidden.bs.modal', function () {
  $("#myCarousel").carousel(0);
});

Upvotes: 1

Related Questions