Jquery to open Bootstrap v3 modal of remote url

后端 未结 6 1236
孤街浪徒
孤街浪徒 2020-12-01 08:02

I have a page of links to internal pages I need to open up in a Bootstrap modal DIV. The problem is that it seems that using the latest version of Bootstrap v3 in conjunctio

6条回答
  •  情话喂你
    2020-12-01 08:38

    If using @worldofjr answer in jQuery you are getting error:

    e.relatedTarget.data is not a function

    you should use:

    $('#myModal').on('show.bs.modal', function (e) {
        var loadurl = $(e.relatedTarget).data('load-url');
        $(this).find('.modal-body').load(loadurl);
    });
    

    Not that e.relatedTarget if wrapped by $(..)

    I was getting the error in latest Bootstrap 3 and after using this method it's working without any problem.

提交回复
热议问题