El sabueso de Twitter: ¿Cuál es el equivalente de "% QUERY" cuando se usa ajax.data y POST?
Si uno usa Bloodhound con GET:
// Typeahead
personsBloodhound = new Bloodhound({
datumTokenizer: function (person) { return person.name; },
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/ajax/Persons/List?nameContains=%QUERY',
ajax: {
beforeSend: function(xhr) {
$(".searching-person").show();
},
data: {
"pageSize": 4,
"otherParam1": "blah",
"otherParam2": "bleh",
}
},
filter: function (response) {
$(".searching-person").hide();
return response.persons;
}
}
});
Uno simplemente usa% QUERY en la URL.
Ahora....
Si uno usa Bloodhound con POST, ¿qué debo usar en lugar de% QUERY?
// Typeahead
personsBloodhound = new Bloodhound({
datumTokenizer: function (person) { return person.name; },
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/ajax/Persons/List',
ajax: {
type: "POST",
beforeSend: function(xhr) {
$(".searching-person").show();
},
data: {
"nameContains": ....WHAT GOES HERE?????......
"pageSize": 4,
"otherParam1": "blah",
"otherParam2": "bleh",
}
},
filter: function (response) {
$(".searching-person").hide();
return response.persons;
}
}
});
Si no estaba claro, la pregunta es:
¿Cuál es el equivalente de%QUERY
cuando usas POST dentro del control remoto de Bloodhound?
La documentación no es clara sobre esto, (prueba):https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md#remote
También intenté usar:
"nameContains": $("#my-input-that-uses-typeahead").val(),
Pero no funcionó.