Javascript Opencart 1.5.6删除模块上的类别自动完成
试图删除模块上的自动完成功能,我想让它列出所有类别,并带有复选框进行选择,而不是自动完成,下面是代码的外观,有什么建议吗?我知道3号线需要一些改变Javascript Opencart 1.5.6删除模块上的类别自动完成,javascript,php,opencart,Javascript,Php,Opencart,试图删除模块上的自动完成功能,我想让它列出所有类别,并带有复选框进行选择,而不是自动完成,下面是代码的外观,有什么建议吗?我知道3号线需要一些改变 .'<tr class="category" '.(($this->data['xshippingpro']['category'][$no_of_tab]!=1)?'style="display:table-row"':'').'>' .'<td>'.$this->data['
.'<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>'
这是代码的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');
}
});
$('input[name=\'category\']')。自动完成({
延误:500,
来源:功能(请求、响应){
$.ajax({
url:'index.php?route=shipping/xshippingpro/get_categories&token=&filter_name='+encodeURIComponent(request.term),
数据类型:“json”,
成功:函数(json){
响应($.map(json,函数(项){
返回{
标签:item.name,
值:item.category\u id
}
}));
}
});
},
选择:功能(事件、用户界面){
var no_of_tab=$(this).closest('div.shipping').attr('id');
否_of_tab=否_of_tab.replace('shipping-','');
_tab的编号=parseInt(_tab的编号);
$(“#表单#配送-”+第#个标签+”.产品类别“+ui.item.value).remove();
$(“#表单#发货-”+第#页+产品类别”)。附加(“”+ui.item.label+“”);
返回false;
},
焦点:功能(事件、用户界面){
返回false;
}
});
$('.product category div img').live('单击',函数()){
var no_of_tab=$(this).closest('div.shipping').attr('id');
否_of_tab=否_of_tab.replace('shipping-','');
_tab的编号=parseInt(_tab的编号);
$(this.parent().remove();
});
$('select.category selection').live('change',function(){
var no_of_tab=$(this).closest('div.shipping').attr('id');
否_of_tab=否_of_tab.replace('shipping-','');
_tab的编号=parseInt(_tab的编号);
if($(this).val()=='1'){
$(“#form#shipping-”+no#u of_tab+“tr.category”).css('display','none');
}否则{
$(“#form#shipping-”+no#u of_tab+“tr.category”).css('display','table row');
}
});
自动完成部分是Javascript吗?如果是这样的话,您的需求我想让它列出所有类别,并带有复选框供选择,而不是自动完成也可以是javascript吗?它不必通过javascript或ajax更新。。。只需选中复选框并保存即可。。。我已经添加了代码的javascript部分。然后,您似乎应该修改服务器端脚本index.php?route=shipping/xshippingpro/get_categories
。。。你是不是没写就进入了这个代码库?如果是这样,服务器端代码也应该在opencart上发布由控制器文件处理的相关部分。代码的第一部分。我想那是我的困惑。为什么在你看来这不是一个javascript问题?自动完成部分是javascript吗?如果是这样的话,您的需求我想让它列出所有类别,并带有复选框供选择,而不是自动完成也可以是javascript吗?它不必通过javascript或ajax更新。。。只需选中复选框并保存即可。。。我已经添加了代码的javascript部分。然后,您似乎应该修改服务器端脚本index.php?route=shipping/xshippingpro/get_categories
。。。你是不是没写就进入了这个代码库?如果是这样,服务器端代码也应该在opencart上发布由控制器文件处理的相关部分。代码的第一部分。我想那是我的困惑。在你看来,为什么这不是一个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');
}
});