我需要确认删除使用引导3模式框(是/否)。怎么可以创建呢?
<form action ="<?PHP echo $URL .'/admin/privileges.PHP?action=editable' ?>" method="POST"> <button class='btn btn-danger btn-xs' type="submit" name="remove_levels" value="delete"><span class="fa fa-times"></span> delete</button></td> </form>
解决方法
工作演示
http://jsfiddle.net/L3ddq/1/
你需要在你的HTML模态。当删除按钮被点击时,它弹出模态。防止点击该按钮提交表单也很重要。单击确认后,提交表单。
<form action ="<?PHP echo $URL .'/admin/privileges.PHP?action=editable' ?>" method="POST"> <button class='btn btn-danger btn-xs' type="submit" name="remove_levels" value="delete"><span class="fa fa-times"></span> delete</button> </form> <div id="confirm" class="modal hide fade"> <div class="modal-body"> Are you sure? </div> <div class="modal-footer"> <button type="button" data-dismiss="modal" class="btn btn-primary" id="delete">Delete</button> <button type="button" data-dismiss="modal" class="btn">Cancel</button> </div> </div>
jQuery
$('button[name="remove_levels"]').on('click',function(e){ var $form=$(this).closest('form'); e.preventDefault(); $('#confirm').modal({ backdrop: 'static',keyboard: false }) .one('click','#delete',function() { $form.trigger('submit'); // submit the form }); // .one() is NOT a typo of .on() });