Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search with Special Characters not working #353

Open
twinkshah743 opened this issue Jun 18, 2018 · 1 comment
Open

Search with Special Characters not working #353

twinkshah743 opened this issue Jun 18, 2018 · 1 comment

Comments

@twinkshah743
Copy link

Hii,

I am using ajax post to send the data where in my phrase is '10+1'. It shows response in console but the ul structure is not formed. It works properly when the phrase is '10+'. Any character after a special character results in no data in dropdown.

This is my js code:

function productidajax(parentelement) { var productCodeoptions = { url: function (phrase) { return config.productlistname; }, getValue: function (element) { // console.log(element.product_name); return element.product_name; }, ajaxSettings: { dataType: "json", method: "POST", data: { dataType: "json" }, success: function (response) { console.log(response); if ($.isEmptyObject(response)) { $("#" + parentelement + " .product_id_cust").val(""); } }, }, preparePostData: function (data) { data.sales_org = jQuery('#organization').val(); data.phrase = $("#" + parentelement + " .product_id_cust").val(); data._token = $('meta[name="csrf-token"]').attr('content'); return data; }, placeholder: "Sélectionnez le produit", requestDelay: 1000, list: { onSelectItemEvent: function () { /*var selectedItemValue = $(this).getSelectedItemData().customer_id; // console.log(selectedItemValue); $("#client_id_pc").val(selectedItemValue).trigger("change");*/ var selectedItemValue = $("#" + parentelement + " .product_id_cust").getSelectedItemData().product_id; fillDetailsUsingId(selectedItemValue,parentelement); }, match: { enabled: true }, } }; setTimeout(function(e){ $("#" + parentelement + " .product_id_cust").easyAutocomplete(productCodeoptions); },2000) }

And this is in my controller:

$sales_org = $request->input('sales_org'); $phrase = $request->input('phrase'); $product_list = DB::table('product') ->select('product_id','product_ean','product_name','product_sku','product_unit','product_volume') ->where('sales_org', $sales_org) ->where('product_name','like',"%$phrase%") ->get(); echo json_encode($product_list);

@kaoson
Copy link

kaoson commented Jul 9, 2021

if (event.keyCode > 40 || event.keyCode === 8 || event.keyCode === 0) {

to

if (event.keyCode > 40 || event.keyCode === 8 || event.keyCode === 32) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants