Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. var $limitQty = $('#product_name_1').val();
  2. $('#product_name_1'+$orderItem_id).on('mouseup keyup', function () {
  3. $(this).val(Math.min({{$remainingDeliveries}}, Math.max(0, $(this).val())));
  4. });
  5.  
  6. //autocomplete script
  7. $(document).on('focus','.autocomplete_txt',function(){
  8. type = $(this).data('type');
  9.  
  10. if(type =='product_code' )autoType='product_code';
  11. if(type =='product_name' )autoType='name';
  12. // if(type =='qty_in' )autoType='qty_in';
  13. // if(type =='product_id' )autoType='id';
  14.  
  15. $(this).autocomplete({
  16. minLength: 0,
  17. source: function( request, response ) {
  18. $.ajax({
  19. url: "{{ route('searchStock') }}",
  20. dataType: "json",
  21. data: {
  22. term : request.term,
  23. type : type,
  24. },
  25. success: function(data) {
  26. var array = $.map(data, function (item) {
  27. return {
  28. label: item[autoType],
  29. value: item[autoType],
  30. data : item
  31. }
  32. });
  33. response(array)
  34. }
  35. });
  36. },
  37. select: function( event, ui ) {
  38. var data = ui.item.data;
  39. id_arr = $(this).attr('id');
  40. id = id_arr.split("_");
  41. elementId = id[id.length-1];
  42. $('#product_code_'+elementId).val(data.product_code);
  43. $('#product_name_'+elementId).val(data.name);
  44. $('#qty_in_'+elementId).val(data.qty_in);
  45. $('#qty_out_'+elementId).val(data.qty_out);
  46. $('#product_id_'+elementId).val(data.id);
  47. }
  48. });
  49. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement