$(document).ready(function(){ var that = this; that.AjaxCurrent = []; that.language = { "NO_RESULT": "Aucun resultat", "ERROR": "Une erreur est survenue" } that.completeObject = function(object) { //EXEMPLE if(object.action == 'getProducts') { } return object; } $('body').on('click', function(e){ var target = $( e.target ); if ( target.is( 'li.input-search-result' ) || target.is('.input-search-js')) { return; } $('.searchResult').hide(); }); $('.input-search-js').each(function(){ var object = {}; object.urlAjax = searchUrl; object.id = $(this).attr('id'); object.$input = $(this); object.$idContentResultList = $('#content-result-list-'+object.id); object.$idContentSelected = $('#content-selected-'+object.id); object.action = object.$input.data('action'); object.typeDisplay = object.action; object.currentAjax = null; object.data_query = {}; object.inputNameElement = 'input-'+object.id+'[]'; object.classNameElement = 'class-'+object.id; object.keys = []; object = that.completeObject(object); if(object.$idContentResultList.size() == 0) console.log('#content-result-list-'+object.id+' not exist'); if(object.$idContentSelected.size() == 0) console.log('#content-selected-'+object.id+' not exist'); object.$idContentResultList.on('click', 'li', function(){ object.addKey($(this).data('id'), $(this).html()); object.$idContentResultList.html(''); object.$input.val('').focus(); }); object.$idContentSelected.on('click', 'li .removeItem', function(){ object.removeKey($(this).parent().data('id')); }); object.$idContentSelected.find('li').each(function(){ var id = $(this).data('id') object.keys[id] = id; }); object.addKey = function(id, html){ if(typeof(object.keys[id]) == 'undefined') { var content = ''; content += '