<div class="right-part ap-search-8">
<h5 class="insta-search-head"><?php echo \Application\Plugin\Common::z_xlt('Instant Search Filters'); ?>:</h5>
<label class="tag alltags" title="<?php echo \Application\Plugin\Common::z_xlt('All Tags'); ?>">
<input type="checkbox">
<span class="tag-text"><?php echo \Application\Plugin\Common::z_xlt('All Tags'); ?></span>
</label>
<?php
$default_filters = (empty($GLOBALS['zhemr']['default_patient_search_filters'])) ? array('fname|lname|mname','pd_pid'): (array)$GLOBALS['zhemr']['default_patient_search_filters']; ?>
<label class="tag <?php if(in_array('fname|lname|mname',$default_filters)){ ?>ap-search-9<?php }?>" data-filter="fname|lname|mname" title="<?php echo \Application\Plugin\Common::z_xlt('Name'); ?>">
<input type="checkbox">
<span class="tag-text"><?php echo \Application\Plugin\Common::z_xlt('Name'); ?></span>
</label>
<label class="tag <?php if(in_array('pd_pid',$default_filters)){ ?>ap-search-9<?php }?>" data-filter="pd_pid" title="<?php echo \Application\Plugin\Common::z_xlt('PID'); ?>">
<input type="checkbox">
<span class="tag-text"><?php echo \Application\Plugin\Common::z_xlt('PID'); ?></span>
</label>
<?php foreach($this->filters as $field_id => $filter) :
?>
<label class="tag <?php if(in_array($field_id,$default_filters)){ ?>ap-search-9<?php }?>" data-filter="<?php echo $field_id; ?>" title="<?php echo \Application\Plugin\Common::z_xlt($filter); ?>">
<input type="checkbox">
<span class="tag-text"><?php echo \Application\Plugin\Common::z_xlt($filter); ?></span>
</label>
<?php
endforeach;
?>
</div>
$(".ap-search-8 .tag").click(function(ev) {
if (!$(this).hasClass("alltags")) {
ev.preventDefault();
if ($(this).hasClass("ap-search-9")) {
if ($(".ap-search-9").length < 2) return;
$(this).removeClass("ap-search-9");
$(this).removeClass("ap-search-adv");
$(this).find("input[type='checkbox']").removeAttr('checked');
} else {
$(this).addClass("ap-search-9");
$(this).addClass("ap-search-adv");
$(this).find("input[type='checkbox']").attr('checked', "checked");
}
} else {
if ($(this).find("input[type='checkbox']").is(":checked")) {
//$(".ap-search-8 .tag").not(".alltags").addClass('ap-search-9');
$(".ap-search-8 .tag").not(".alltags").addClass('ap-search-9').find("input[type='checkbox']").attr('checked', "checked");
} else {
//(".ap-search-8 .tag").not(".alltags").removeClass('ap-search-9');
$(".ap-search-8 .tag").not(".alltags,[data-filter='fname|lname|mname'],[data-filter='pd_pid']").removeClass('ap-search-9').find("input[type='checkbox']").removeAttr('checked');
}
}
var filter_fields = "";
var i = 0;
top.$(".ap-search-9").each(function() {
i++;
if (filter_fields != '') filter_fields += "****";
filter_fields += $(this).attr("data-filter");
});
if ($('.ap-search-8').find('.ap-search-9').length == $('.ap-search-8').find('label.tag').not('.alltags').length) {
$('.ap-search-8').find('.alltags').find("input[type='checkbox']").prop('checked', 'true');
} else {
$('.ap-search-8').find('.alltags').find("input[type='checkbox']").removeAttr('checked');
}
angular.element($('#angular_jquery_map')).scope().filterFields = filter_fields;
requestRunning = true;
memorizeSearchFilters();
return false;
});
此处,“Alltags”标签的点击功能会发生两次,其他标签也会正常工作。如果我们将preventDefault()函数放在if条件之外,那么点击就会变好,但是其他部分,即单击为'Alltags'写的不起作用。复选框选中并取消选中不会发生。如果有人知道解决方案,请帮助。