TypeError: $(…).modal is not a function with bootstrap Modal

前端 未结 14 1892

I have a bootstrap 2.32 modal which I am trying to dynamically insert into the HTML of another view. I\'m working with Codeigniter 2.1. Following Dynamically inserting a boo

14条回答
  •  孤城傲影
    2020-11-29 04:46

    Other answers din't work for me in my react.js application, so I have used plain JavaScript for this.

    Below solution worked:

    1. Give an id for close part of the modal/dialog ("myModalClose" in below example)
    
       className="close cursor-pointer"
       data-dismiss="modal"
       aria-label="Close"
                         id="myModalClose"
    >
    ...
    
    1. Generate a click event to the above close button, using that id:
       document.getElementById("myModalClose").click();
    

    Possibly you could generate same click on close button, using jQuery too.

    Hope that helps.

提交回复
热议问题