js代码
function initView(_box){ var $p = $(_box || document); $('a[target="dialog"]', $p).each(function(event){ $(this, $p).unbind('click').click(function(event){ openModal(event); }); }); } $(function(){ initView(); }); /**关闭modal*/ function hideModal(obj){ var modal = $(obj).parents("div.modal"); if(modal.length > 0){ modal.remove(); initView(); } } /**打开modal*/ function openModal(event){ // var this = $(this); var $this = $(event.currentTarget); var _url = $this.attr("href"); var _title = $this.attr("title"); var _id; _id = dialog.content(); var options = { backdrop: false, keyboard: true, show: true }; $('#' + _id).modal(options); var modal = $('#' + _id); if(typeof(_title) != "undefined"){ if(modal.find('.modal-title').length <= 0){ var header = dialog.header({title : _title}); $($.parseHTML(header)).appendTo(modal.find(".modal-content")); }else{ modal.find('.modal-title').text(_title); } if(modal.find('.modal-body').length <= 0){ var _body = dialog.body; $($.parseHTML(_body)).appendTo(modal.find(".modal-content")); } modal.find(".modal-body").load(_url, $.proxy(function () { modal.trigger('loaded.bs.modal'); initView(); }, this)); }else{ modal.find(".modal-content").load(_url, $.proxy(function () { modal.trigger('loaded.bs.modal'); initView(); }, this)); } //阻止事件默认行为 event.preventDefault(); } //modal model //TO STRAT if(!$(window).data("_modal_id")){ $(window).data("_modal_id", 0); } var dialog = { header : function(options){ var template = '<div class="modal-header">' + '<button type="button" class="close" aria-label="Close" onclick="hideModal(this);"><span aria-hidden="true">×</span></button>' + '<h4 class="modal-title">' + options.title + '</h4>' +'</div>'; return template; }, content : function(){ var _modal_id = $(window).data("_modal_id"); var _id = "_modal_id_" + _modal_id; _modal_id ++; $(window).data("_modal_id", _modal_id); var template = '<div class="modal fade" tabindex="-1" role="dialog" id="'+ _id +'">' + '<div class="modal-dialog modal-lg" role="document" aria-hidden="true">' + '<div class="modal-content">' + '</div>' + '</div>' +'</div>'; $(template).appendTo('body'); initView(); return _id; }, body : '<div class="modal-body"></div>' }; //TO END
页面代码:
<a href="select.html" rel="external nofollow" id="signId" class="btn btn-info" <span style="background-color: rgb(255, 255, 102);">target="dialog"</span> title="请选择用餐类型">签到</a>
页面上只要在a标签后加上target="dialog",并且提供href外部链接地址就可以弹出modal框
以上所述是小编给大家介绍的扩展bootstrap的modal模态框-动态添加modal框-弹出多个modal框,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“扩展bootstrap的modal模态框-动态添加modal框-弹出多个modal框”评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新动态
2024年05月09日
2024年05月09日
- 《披萨塔,Pizza Tower》基础攻略 简述+配置+下载
- 中唱唱片群星《好歌珍藏-母爱·亲情》2CD[WAV+CUE]
- 中唱唱片群星《好歌珍藏-大地飞歌》2CD[WAV]
- 金海心-那么骄傲[WAV]
- 数毛社分析PS5 Pro规格:GPU主频高达2.35GHz
- 《死侍3》新正片片段:狼叔被死侍硫酸脸恶心到了
- 《地狱潜者2》CEO赞扬社区玩家:你们的意志与合作力让我印象深刻
- 张学友 歌神《等风雨经过3CD》[WAV+CUE][2GB]
- 华语流行《周杰伦 2022最伟大的作品》[FLAC/分轨][1.7GB]
- 孙燕姿《No. 13作品 跳舞的梵谷》[WAV+CUE][400MB]
- 张心柔.2012-吟游诗人【禾广娱乐】【FLAC分轨】
- 关淑怡.1991-恋一世的爱【宝丽金】【WAV+CUE】
- 群星.2010-我的舞台·2010快乐男声【天娱传媒】【WAV+CUE】
- 崩坏星穹铁道最新5月兑换码汇总 崩铁2024年兑换码分享
- 崩坏星穹铁道椒丘是男还是女 崩铁椒丘性别介绍