var ComponentsTypeahead = function () {
var handleTwitterTypeahead_clienti = function() {
// QUERY PHP MYSQL
var custom_cliente = new Bloodhound({
datumTokenizer: function(d) { return d.tokens; },
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: 'php/auto_complete.php?ID=ID_CLIENTE&tabella=GT_CLIENTE&campo=RagSoc_Cli_Finale&query=%QUERY',
wildcard: '%QUERY'
}
});
custom_cliente.initialize();
if (App.isRTL()) {
$('#cerca_clienti').attr("dir", "rtl");
}
$('#cerca_clienti').typeahead(null, {
name: 'cerca_clienti',
displayKey: 'value',
source: custom_cliente.ttAdapter(),
hint: (App.isRTL() ? false : true),
templates: {
suggestion: Handlebars.compile([
'
',
].join(''))
}
}).bind("typeahead:selected typeahead:autocompleted", function(e,datum,name) { $("#ID_CLIENTE").val(datum.tokens); });
}
var handleTwitterTypeahead_consulenti = function() {
// QUERY PHP MYSQL
var custom_consulente = new Bloodhound({
datumTokenizer: function(d) { return d.tokens; },
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: 'php/auto_complete.php?ID=ID_CONSULENTE&tabella=GT_CONSULENTE&campo=username&query=%QUERY',
wildcard: '%QUERY'
}
});
custom_consulente.initialize();
if (App.isRTL()) {
$('#cerca_consulenti').attr("dir", "rtl");
}
$('#cerca_consulenti').typeahead(null, {
name: 'cerca_consulenti',
displayKey: 'value',
source: custom_consulente.ttAdapter(),
hint: (App.isRTL() ? false : true),
templates: {
suggestion: Handlebars.compile([
'',
].join(''))
}
}).bind("typeahead:selected typeahead:autocompleted", function(e,datum,name) { $("#ID_CONSULENTE").val(datum.tokens); });
}
return {
//main function to initiate the module
init: function () {
handleTwitterTypeahead_consulenti();
handleTwitterTypeahead_clienti();
}
};
}();
jQuery(document).ready(function() {
ComponentsTypeahead.init();
});