更新时间:2023-10-21 21:37:46
使用jQuery,您可以这样做:
with jQuery, you can do this:
$(document).on('click', 'input[name=maincb]', function(){
$('.editable-input').prop('checked', $(this).is(':checked'));
});
DEMO: http://jsfiddle.net/NfPcH/7474/
Hi,Sam。对不起,延迟回复。 Formaly你的答案是正确的
但正如我上面提到的,jquery不处理angularjs模型(或
范围)。所以你可以看到,使用后关闭所有复选框和
保存,仍然处于未归档状态。如何粘贴复选框状态
与模型? - Sharov 26分钟前
Hi, Sam. Sorry for delayed response. Formaly your answer is correct but as I mentioned above jquery doesn't handle angularjs model (or scope). So you can see that after use switch off all checkboxes and save, the still have unchenged state. How to glue checkboxes state with model? – Sharov 26 mins ago
我不是一个有角度的开发者,我敢肯定有一种方法,但这里是使用jQuery做的一个解决方法
I'm not an angular developer, I'm sure there is a way to do that with Angular, but here is a workaround to do it with jQuery
DEMO: http://jsfiddle.net/NfPcH/7505/
$(document).on('click', 'input[name=maincb]', function(){
var checked = $(this).is(':checked');
$('form > div').eq(1).find('.editable-input').each(function(){
if($(this).is(':checked') != checked){
$(this).trigger('click');
}
});
});