Jquery prop()とchange()の競合解決方法
4522 ワード
解決策:change()を追加し、$(「input[type='checkbox’」)をトリガーします.prop(‘checked’, true).change();
コードの例は次のとおりです.
全選択時にchangeメソッドを追加
コードの例は次のとおりです.
$("input[name='paxOdr']:checkbox").change(function(){
console.log("paxOdr>>>>>>>>");
var type = $("#applyMainType").val();
var arip = $("#serviceAirp").val();
if(opt!="'view'" && opt!="view"){
var datas =getCheckDataList('paxStand');//
$("#paxStandList li").remove();
initStandard('1', type, arip, $("#paxStandList"), 'pax','paxStand', 'paxOdr');
$("input[name='paxStand']:checkbox").each(function(i){
ob = $.parseJSON($(this).val());
$.each(datas,function(m){
if(socVos[m].standId == ob.standId && socVos[m].serviceId == ob.serviceId &&socVos[m].id == ob.id){
$("input[name='paxStand']:checkbox")[i].checked=true;
}
});
});
}
});
全選択時にchangeメソッドを追加
if(value=='paxSerList')$("input[name=paxSer]:checkbox").prop("checked", true);
if(value=='paxList')$("input[name=pax]:checkbox").prop("checked", true).change();
if(value=='paxOdrList')$("input[name=paxOdr]:checkbox").prop("checked", true).change();
if(value=='paxStandList')$("input[name=paxStand]:checkbox").prop("checked", true);
if(value=='crewList')$("input[name=crew]:checkbox").prop("checked", true).change();
if(value=='crewOdrList')$("input[name=crewOdr]:checkbox").prop("checked", true).change();
if(value=='crewStandList')$("input[name=crewStand]:checkbox").prop("checked", true);