* Use jquery-ui's autocomplete module instead of typeahead

* Enable support for multiple tag autocomplete
This commit is contained in:
r888888888
2013-06-18 18:36:37 -07:00
parent 08463cdd9e
commit e0a14bb9eb
10 changed files with 100 additions and 68 deletions

View File

@@ -14,13 +14,25 @@
Danbooru.Pool.initialize_add_to_pool_link = function() {
$("#add-to-pool-dialog").dialog({autoOpen: false});
$("#c-pool-elements #a-new input[type=text]").typeahead({
name: "pools",
remote: "/pools.json?search[is_active]=true&search[name_matches]=%QUERY",
limit: 10,
valueKey: "name",
template: function(context) {
return "<p>" + context.name.replace(/_/g, " ") + "</p>";
$("#c-pool-elements #a-new input[type=text]").autocomplete({
source: function(req, resp) {
$.ajax({
url: "/pools.json",
data: {
"search[is_active]": "true"
"search[name_matches]": req.term
},
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.name.replace(/_/g, " "),
value: tag.name
};
}));
}
});
}
});