function init_components_part(input){ if(input.is(":visible")) { var partPicker = input.clone(); input.before(partPicker); if(input.parent().hasClass("input-group")){ input.parent().after(input.detach()); input.before('
'); } input.hide(); partPicker.addClass('data-type-part').removeAttr("data-type").removeAttr('name').removeAttr('id').removeAttr('onchange'); partPicker.attr('data-source',input.attr('id')); }else{ partPicker = $('[data-source="'+input.attr('id')+'"]'); } input.change(function(){ partPicker.prop('disabled',true).val('Chargement...'); $.action({ action : 'get_part_by_id', id : input.val(), before : input.attr('data-before'), },function(r){ partPicker.prop('disabled',input.prop('disabled')); if(r.part && r.part.label){ partPicker.val(r.part.label); }else{ partPicker.val(''); } }); }); if(input.val() !=''){ partPicker.prop('disabled',true).val('Chargement...'); $.action({ action : 'get_part_by_id', id : input.val(), before : input.attr('data-before'), },function(r){ partPicker.prop('disabled',input.prop('disabled')); if(r.part && r.part.label){ partPicker.val(r.part.label); }else{ partPicker.val(''); } }); } partPicker.keyup(function(){ input.val(''); }); var parent = input.attr('data-parent'); partPicker.autocomplete({ action : 'autocomplete_part', data : { before : input.attr('data-before'), parent:function(){ return $(parent).val(); } }, skin : function(item){ var html = ''; name = item.name; /*var re = new RegExp(partPicker.val(),"gi"); name = item.name.replace(re, function (x) { return ''+x+''; });*/ html += ''; html += '