Bootstrap Modal Dynamic Content

后端 未结 3 1153
感动是毒
感动是毒 2021-02-04 09:31

I\'m in need of a method to load dynamic content that can change at any time. According to the Bootstrap documentation

3条回答
  •  执念已碎
    2021-02-04 10:01

    You can properly clear the modal's cache using:

    $('#your-modal').removeData('bs.modal');
    

    See https://github.com/twbs/bootstrap/pull/7935#issuecomment-21166069
    You'd probably want to do that in an event handler for the modal's hidden.bs.modal event.

    Though you're probably better off using client-side templating and a little custom JavaScript to load the necessary data, instead of using data-remote in the first place. Especially since Bootstrap has deprecated the remote modal option.

提交回复
热议问题