我使用jQuery
<a class="deleteit btn btn-danger btn-sm" id="{{service['company']['slug']~'/'~service['customer']['_id']~'/'~service['service']['serviceId']}}" data-toggle="modal" data-target="#delete_dialog_all_services" title="Delete Service"><i class="glyphicon glyphicon-remove"></i></a>
然后我用这个函数将url传递给modal中的form的action属性:
$('.deleteit').click(function (event) {
var myVal = $(this).attr('id');
$('.formDel').attr('action', function(i, value) {
return "{{url_for('services.delete_service',company_name='companyName', customer_id='customerID', service_id='serviceID')}}".replace('companyName/customerID/serviceID', myVal);
});
});
在这个模态中我有一个表单,我使用上面的函数
传递属性操作中的url<!-- modal fail-safe -->
<div id="delete_dialog_all_services" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<a href="#" data-dismiss="modal" aria-hidden="true" class="close">×</a>
<h4>
Confirm!
</h4>
</div>
<div class="modal-body" align="center">
<p><i class="glyphicon glyphicon-warning-sign"></i> This item will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
<div class="modal-footer">
<div class="pull-right">
<div class="col-xs-6">
<form action="" class="formDel" method="get">
<button type="submit" class="btn btn-danger">
Yes
</button>
</form>
</div>
<div class="col-xs-6">
<a href="#" data-dismiss="modal" class="btn btn-default" aria-hidden="true">No</a>
</div>
</div>
</div>
</div>
</div>
我的问题是,当我动态生成,其示出了使用jQuery
它不&#39的模态的链接;吨结合上点击的情况下,因而它不将URL传递到action属性中的模态形式。我认为jQuery
范围或DOM构建有问题,或者我不知道是什么。
提前致谢!