-
Notifications
You must be signed in to change notification settings - Fork 121
Closed
Description
I have a fairly straightforward typeahead that defines an item.href with a {{display}} placeholder.
Since moving from 2.9.0 to 2.10.3, the href can no longer be found (is undefined). Even whey I put in a dummy href, such as "/beer/" it cannot be found. It seem like the same behavior I am seeing on your country v.2 demo.
Is there a change from 2.9.x that might affect the visibility of the href option?
Here is my code:
It is the same href template for all groups, so not specified at the group level.
$.typeahead({
input: ".js-typeahead",
minLength: 1,
order: "asc",
group: true,
maxItemPerGroup: 3,
hint: true,
dropdownFilter: "All Types",
href: "/resource-sharing/databases/links.php?locid={{display}}",
template: "{{display}}",
emptyTemplate: "no result for {{query}}",
source: {
public: {
data: data.publics
},
academic: {
data: data.academics
},
school: {
data: data.schools
},
special: {
data: data.specials
}
},
callback: {
onClickAfter: function (node, a, item, event) {
event.preventDefault();
var str = item.href;
**alert(str);**
var re = /(^.*=).*\[(.*)\]$/i;
var newhref = str.replace(re, "$1$2");
$(location).attr('href',newhref);
},
onResult: function (node, query, obj, objCount) {
console.log(objCount)
var text = "";
if (query !== "") {
text = objCount + ' elements matching "' + query + '"';
}
$('.js-result-container').text(text);
}
},
debug: true
});