javascript 复选框 - 仅在引导模式确定时取消选中
javascript checkbox - uncheck only on bootstrap modal OK
我有一个复选框,我需要添加一些javascript。
我在使其工作时遇到问题,因为我有一个具有"取消"和"确认"按钮的引导模式。
我不确定如何将取消选中引用传递给模态代码并取消选中"确认"按钮上的复选框。我做过很多次尝试,但都失败了。
如何仅在用户选择引导模式上的"确认"按钮时才取消选中复选框。当用户选择模式"取消"按钮时,该复选框应保持选中状态。
这是我目前拥有的复选框代码:
<input type="checkbox" name="selected_items" value="{{ id }}" {% if selected %}checked="checked"{% endif %} data-confirm="Are you sure you want to uncheck this?" />
这是我拥有的引导模式代码:
$(document).ready(function() {
$('input[data-confirm]').click(function(ev) {
var href = $(this).attr('href');
if (!$('#dataConfirmModal').length) {
$('body').append('<div id="dataConfirmModal" class="modal modal-confirm-max-width" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true"><icon class="icon-remove"></icon></button><h4 class="modal-title" id="dataConfirmLabel">{% trans "Confirm" %} - {{ resume_detail_temp_value }}</h4></div><div class="modal-body"></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button> <a class="btn-u btn-u-blue" id="dataConfirmOK">{% trans "Confirm" %}</a></div></div>');
}
$('#dataConfirmModal').find('.modal-body').html($(this).attr('data-confirm'));
$('#dataConfirmModal').modal({show:true});
$('#dataConfirmOK').click(function() {
// handle checkbox function here.
});
return false;
});
});
这是你要找的吗?
$('#dataConfirmOK').click(function() {
$('input[name=selected_items]').prop('checked', false);
});
相关文章:
- 如何在angularJS中编辑时,如果DB中的值为true,则设置复选框,如果值为false,则取消选中复选框
- jquery点击函数select&取消选择
- 绑定时将Parsley minlength消息作为选项传递时,未对其进行自定义
- 使用Jquery选择或取消选择ListView中的所有复选框
- 使用jquery选中/取消选中单个复选框
- 使用javascript取消隐藏和隐藏表单中的某些元素
- 如何销毁/删除/取消绑定SnapSVG.js
- 滚动然后捕捉到顶部而不是取消捕捉
- 取消绑定主干视图事件
- 如何取消object.prototypes javascript的一个函数
- 使用javascript在页面加载时取消选中所有复选框
- 阻止浏览器对keydown事件作出反应,但不取消该事件
- jquery选中并取消选中所有操作
- IE11中的第二个调用取消了第一个Fetch API调用
- 定时Ajax进程在用户离开页面后继续
- 将菜单项与滚动绑定时出现Jquery错误
- 如何知道使用socket.io订阅/取消订阅频道
- 定时循环,使用Javascript在2个循环之间间隔x秒
- 定时循环,间隔10秒
- 如何通过单击取消javascript函数启动的定时重定向