javascript - Opencart 1.5.6 删除模块上的类别自动完成
问题描述
试图删除模块上的自动完成功能,我想让它列出所有类别,并带有一个复选框以供选择而不是自动完成,这是代码的样子,有什么建议吗?我知道它需要在第 3 行进行一些更改。
.'<tr class="category" '.(($this->data['xshippingpro']['category'][$no_of_tab]!=1)?'style="display:table-row"':'').'>'
.'<td>'.$this->data['entry_category'].'</td>'
.'<td><input type="text" name="category" value="" /></td>'
.'</tr>'
.'<tr class="category" '.(($this->data['xshippingpro']['category'][$no_of_tab]!=1)?'style="display:table-row"':'').'>'
.'<td> </td>'
.'<td><div class="scrollbox product-category">';
foreach ($this->data['xshippingpro']['product_category'][$no_of_tab] as $category_id) {
$category_name=$this->getPath($category_id);
$return.='<div class="product-category'.$category_id. '">'.$category_name.'<img src="view/image/delete.png" alt="" />'
.'<input type="hidden" class="category" name="xshippingpro[product_category]['.$no_of_tab.'][]" value="'.$category_id.'" /></div>';
}
$return.='</div></td>'
.'</tr>'
这是处理获取数据调用的代码的另一部分......
public function get_categories() {
$json = array();
if (isset($this->request->get['filter_name'])) {
$results = $this->getCategories($this->request->get['filter_name']);
foreach ($results as $result) {
$json[] = array(
'category_id' => $result['category_id'],
'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8'))
);
}
}
$sort_order = array();
这是代码的javascript部分
$('input[name=\'category\']').autocomplete({
delay: 500,
source: function(request, response) {
$.ajax({
url: 'index.php?route=shipping/xshippingpro/get_categories&token=<?php echo $token; ?>&filter_name=' + encodeURIComponent(request.term),
dataType: 'json',
success: function(json) {
response($.map(json, function(item) {
return {
label: item.name,
value: item.category_id
}
}));
}
});
},
select: function(event, ui) {
var no_of_tab=$(this).closest('div.shipping').attr('id');
no_of_tab=no_of_tab.replace('shipping-','');
no_of_tab=parseInt(no_of_tab);
$('#form #shipping-'+no_of_tab+' .product-category' + ui.item.value).remove();
$('#form #shipping-'+no_of_tab+' .product-category').append('<div class="product-category' + ui.item.value + '">' + ui.item.label + '<img src="view/image/delete.png" alt="" /><input type="hidden" class="category" name="xshippingpro[product_category]['+no_of_tab+'][]" value="' + ui.item.value + '" /></div>');
return false;
},
focus: function(event, ui) {
return false;
}
});
$('.product-category div img').live('click', function() {
var no_of_tab=$(this).closest('div.shipping').attr('id');
no_of_tab=no_of_tab.replace('shipping-','');
no_of_tab=parseInt(no_of_tab);
$(this).parent().remove();
});
$('select.category-selection').live('change', function() {
var no_of_tab=$(this).closest('div.shipping').attr('id');
no_of_tab=no_of_tab.replace('shipping-','');
no_of_tab=parseInt(no_of_tab);
if($(this).val()=='1'){
$('#form #shipping-'+no_of_tab+' tr.category').css('display', 'none');
}else{
$('#form #shipping-'+no_of_tab+' tr.category').css('display', 'table-row');
}
});
解决方案
推荐阅读
- javascript - 避免 keyup 输入 ajax 调用的重复结果;杀死以前的ajax调用
- java - 外部化属性文件 - Widlfly & Struts 1.x
- oracle - 将 SQL 脚本作为 Windows 批处理文件运行
- c# - 拆分多个 linq include()
- android - 如何使用 Kotlin 从非活动类中查找 ListView?
- php - 如何处理内联 SVG 的重复 ID?
- angularjs - angularjs 1.7 选择下拉菜单显示了一个额外的选项值
- ios - 如何在另一个视图控制器(swift)中隐藏状态栏+使用白光内容?
- loopback - 我在 Loopback 中遇到问题
- r - R - 如何一次操作数据集的所有子集