我正在使用Twitter Bootstrap 3,我希望有一个表单,当我提交它时,模态会出现问我“你确定要删除人物”是否有任何方法使按钮在那里提交刚刚填写的表格?
在其他示例中,我使用过按钮的链接,该链接是site.com/do_delete_person/person_id_18的链接,这是JS文件中的modalUrl
<a href="' + modalUrl + '" class="btn btn-primary showhouse-colour">
<i class="icon-ok"></i> Yes
</a>
<button class="btn" data-dismiss="modal" aria-hidden="true">
<i class="icon-ban-circle"></i> No
</button>
但为此,我需要模式提交前面的表格
答案 0 :(得分:1)
这是我的解决方案..我使用window.location将它们重定向到确认后删除网址
<!-- Button trigger modal -->
<a data-toggle="modal" href="#" class="delete-item btn btn-primary btn-lg" data-id="25">Launch demo modal</a>
<!-- Modal -->
<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">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<input type="hidden" value="" id="delete-url"/>
Are you sure you want to delete this item?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary confirm">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
jQuery(document).ready(function(){
jQuery('.delete-item').click(function(){
var id = jQuery(this).attr('data-id');
var delete_url = 'http://yourdomain.com/delete/'+id;
jQuery('#delete-url').val(delete_url);
jQuery("#myModal").modal('show');
});
jQuery('.confirm').click(function(){
window.location = jQuery('#delete-url').val();
});
});