in joomla 3 how to include auto complete search

2019-08-30 20:27发布

问题:

I am creating custom component,in that In that am creating product category list box by using custom fieldtype (mycomponent/models/fields/productcategory.php). It also showing the product cagetory in right manner.

i need to create select listbox with auto complete search like position field in module manager..

Any one know the solution..

回答1:

I have solved my problem using select.js.

The jQuery coding is:

jQuery(document).ready(function($) {
  jQuery(".productcat").change(function(){
    fk_productcat = $("#" + this.id).val();
    //alert(fk_productcat);
    jQuery.ajax({
      url:'index.php?option=com_gwerp&task=stocks.getListArticles',
      type: "POST",
      data: {
        'fk_productcat': fk_productcat
      }
    }).done(function(msg) {
      console.log(msg);
      jQuery(".product").html(msg);
      jQuery( ".product" ).val(msg).trigger( "liszt:updated" );
      jQuery("#jform_fk_product_code").select2();
    })
  })
});

jQuery(document).ready(function() {
  jQuery("#jform_fk_productcat").select2();
});

jQuery(document).ready(function() {
  jQuery("#jform_fk_product_code").select2();
});

I called Ajax file by refer this url.