forked from Wavyzz/dolibarr
FIX #3865 ajax_autocompleter triggers twice change() JS event over #search_htmlname
Close #3865
This commit is contained in:
@@ -52,16 +52,13 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
|||||||
// Remove product id before select another product
|
// Remove product id before select another product
|
||||||
// use keyup instead change to avoid loosing the product id
|
// use keyup instead change to avoid loosing the product id
|
||||||
$("input#search_'.$htmlname.'").keydown(function() {
|
$("input#search_'.$htmlname.'").keydown(function() {
|
||||||
//console.log(\'purge_id_after_keydown\');
|
|
||||||
$("#'.$htmlname.'").val("");
|
$("#'.$htmlname.'").val("");
|
||||||
});
|
});
|
||||||
$("input#search_'.$htmlname.'").change(function() {
|
$("input#search_'.$htmlname.'").change(function() {
|
||||||
//console.log(\'change\');
|
|
||||||
$("#'.$htmlname.'").trigger("change");
|
$("#'.$htmlname.'").trigger("change");
|
||||||
});
|
});
|
||||||
// Check when keyup
|
// Check when keyup
|
||||||
$("input#search_'.$htmlname.'").keyup(function() {
|
$("input#search_'.$htmlname.'").keyup(function() {
|
||||||
//console.log(\'keyup\');
|
|
||||||
if ($(this).val().length == 0)
|
if ($(this).val().length == 0)
|
||||||
{
|
{
|
||||||
$("#search_'.$htmlname.'").val("");
|
$("#search_'.$htmlname.'").val("");
|
||||||
@@ -127,7 +124,6 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
minLength: '.$minLength.',
|
minLength: '.$minLength.',
|
||||||
select: function( event, ui ) { // Function ran when new value is selected into javascript combo
|
select: function( event, ui ) { // Function ran when new value is selected into javascript combo
|
||||||
//console.log(\'set value of id with \'+ui.item.id);
|
|
||||||
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
|
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
|
||||||
// Disable an element
|
// Disable an element
|
||||||
if (options.option_disabled) {
|
if (options.option_disabled) {
|
||||||
@@ -171,8 +167,6 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log("ajax_autocompleter new value selected, we trigger change");
|
|
||||||
$("#search_'.$htmlname.'").trigger("change"); // To tell that input text field was modified
|
|
||||||
}
|
}
|
||||||
,delay: 500
|
,delay: 500
|
||||||
}).data("ui-autocomplete")._renderItem = function( ul, item ) {
|
}).data("ui-autocomplete")._renderItem = function( ul, item ) {
|
||||||
|
|||||||
@@ -523,7 +523,6 @@ jQuery(document).ready(function() {
|
|||||||
/* When changing predefined product, we reload list of supplier prices */
|
/* When changing predefined product, we reload list of supplier prices */
|
||||||
$("#idprod, #idprodfournprice").change(function()
|
$("#idprod, #idprodfournprice").change(function()
|
||||||
{
|
{
|
||||||
console.log("change #idprod, #idprodfournprice, conf->global->MARGIN_TYPE=<?php echo $conf->global->MARGIN_TYPE ?>");
|
|
||||||
setforpredef();
|
setforpredef();
|
||||||
jQuery('#trlinefordates').show();
|
jQuery('#trlinefordates').show();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user