I am using mention.js basic example
$('textarea.mention-example2').mentionsInput({
onDataRequest:function (mode, query, callback) {
$.getJSON('DataTableJsonFils/systmeQ.json', function(responseData) {
responseData = _.filter(responseData, function(item) { return item.name.toLowerCase().indexOf(query.toLowerCase()) > -1 });
callback.call(this, responseData);
});
}
});
I have this json array as the data for this example
[
{
"id": 1,
"name": "Kenneth Auchenberg",
"avatar": "http://cdn0.4dots.com/i/customavatars/avatar7112_1.gif",
"type": "contact"
},
{
"id": 2,
"name": "Jon Froda",
"avatar": "http://cdn0.4dots.com/i/customavatars/avatar7112_1.gif",
"type": "contact"
},
{
"id": 3,
"name": "Anders Pollas",
"avatar": "http://cdn0.4dots.com/i/customavatars/avatar7112_1.gif",
"type": "contact"
},
{
"id": 4,
"name": "Kasper Hulthin",
"avatar": "http://cdn0.4dots.com/i/customavatars/avatar7112_1.gif",
"type": "contact"
},
{
"id": 5,
"name": "Andreas Haugstrup",
"avatar": "http://cdn0.4dots.com/i/customavatars/avatar7112_1.gif",
"type": "contact"
},
{
"id": 6,
"name": "Pete Lacey",
"avatar": "http://cdn0.4dots.com/i/customavatars/avatar7112_1.gif",
"type": "contact"
},
{
"id": 7,
"name": "kenneth@auchenberg.dk",
"avatar": "http://cdn0.4dots.com/i/customavatars/avatar7112_1.gif",
"type": "contact"
}
]
the filter is working fine. my question is how can i get the id value when i select a result from the filter and not the name. I would like to keep filtering over the name value but on select display the id