从其他html文件打开Modal(bootstrap)(Open Modal (bootstrap) from other html

编程入门 行业动态 更新时间:2024-10-24 16:32:11
从其他html文件打开Modal(bootstrap)(Open Modal (bootstrap) from other html-file)

我正在使用bootstrap构建一个网站。 但我有点死路一条。 我已经从给定的例子中创建了一个模态(见下文)。 正如您可能看到的,这是一种直接来自他们网站的模式。

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title" id="myModalLabel">Nieuwe Taak toevoegen</h4> </div> <div class="modal-body"> ... </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div>

我用一个按钮打开这个对话框。

<button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#myModal" >

但我想将我的模态保存在单独的aspx/html-files 。 当它们被保存在不同的html/aspx - files时,我如何打开这些模态?

示例:如果按钮在index.Html内,但模态在newTaskModal.html ,我将如何打开模态? (如果两者都在index.html内,那么没有问题)

注意:我不能/不能使用HTML5(公司标准)

I'm building a website using bootstrap. But i'm come to somewhat of an dead-end. i've created a modal from an given example (see below). As you might see, this is a modal taken straight from their website.

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title" id="myModalLabel">Nieuwe Taak toevoegen</h4> </div> <div class="modal-body"> ... </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div>

I open this dialog using a button.

<button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#myModal" >

But i want to keep my modals in seperate aspx/html-files. How can i open these modals when they are kept inside different html/aspx - files ?

example: if the button is inside index.Html but the modal is inside newTaskModal.html, how would i open the modal? (If both are inside index.html, then there are no problems)

Note: I don't/can't use HTML5 (company-standards)

最满意答案

如果你正在使用jquery,你可以使用ajax调用下载页面:

$.ajax({ url: 'newTaskModal.html', dataType: 'text', success: function(data) { alert(data); // todo: add the html to the dom... } });

如果您正在构建单个页面应用程序,您可能需要查看旨在解决此类问题的框架: durandal

if you're using jquery, you could download the page using an ajax call:

$.ajax({ url: 'newTaskModal.html', dataType: 'text', success: function(data) { alert(data); // todo: add the html to the dom... } });

If you're building a single page application you might want to check out a framework designed to solve this type of problem: durandal

更多推荐

本文发布于:2023-08-05 03:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1427997.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   html   Modal   Open   bootstrap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!