Bootstrap 3 / showing modal doesn't work with the javascript way

折月煮酒 提交于 2019-12-04 05:36:19

i am not sure if i have misunderstood your question.

According to my understanding of your question, you need

$('#myModal').modal({
    show: true,
    remote: '/myNestedContent'
});

you cannot just

$('#myModal').modal('show'); 

because there is no url provided in this js method.

does this solve your question?

What you need to do is remove the data-target from the html tag when used with js, leaving it call twice the function then one shows it and the other removes it. Thats how i solved.

Readers should note that the "remote:" option is being deprecated... per the docs

"This option is deprecated since v3.3.0 and will be removed in v4. We recommend instead using client-side templating or a data binding framework, or calling jQuery.load yourself.

If a remote URL is provided, content will be loaded one time via jQuery's load method and injected into the .modal-content div. If you're using the data-api, you may alternatively use the href attribute to specify the remote source. An example of this is shown below:"

<a data-toggle="modal" href="remote.html" data-target="#modal">Click me</a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!