Changed interface Templates to support Handlebars templates as header, footer and empty.

This commit is contained in:
Marijn Giesen
2014-11-21 10:36:59 +01:00
parent 39531c32fe
commit 3d9320a30f
2 changed files with 36 additions and 3 deletions
+33
View File
@@ -227,6 +227,17 @@ function test_dataset_templates() {
});
}
function with_empty_option_as_a_function() {
$('#the-basics .typeahead').typeahead(options, {
source: substringMatcher(states),
templates: {
empty: function(context: any) {
return context.name;
}
}
});
}
function with_footer_option() {
$('#the-basics .typeahead').typeahead(options, {
source: substringMatcher(states),
@@ -234,6 +245,17 @@ function test_dataset_templates() {
});
}
function with_footer_option_as_a_function() {
$('#the-basics .typeahead').typeahead(options, {
source: substringMatcher(states),
templates: {
footer: function(context: any) {
return context.name;
}
}
});
}
function with_header_option() {
$('#the-basics .typeahead').typeahead(options, {
source: substringMatcher(states),
@@ -241,6 +263,17 @@ function test_dataset_templates() {
});
}
function with_header_option_as_a_function() {
$('#the-basics .typeahead').typeahead(options, {
source: substringMatcher(states),
templates: {
header: function(context: any) {
return context.name;
}
}
});
}
function with_suggestion_option() {
$('#the-basics .typeahead').typeahead(options, {
source: substringMatcher(states),
+3 -3
View File
@@ -137,21 +137,21 @@ declare module Twitter.Typeahead {
* Can be either a HTML string or a precompiled template.
* If it's a precompiled template, the passed in context will contain query
*/
empty?: string;
empty?: any;
/**
* Rendered at the bottom of the dataset.
* Can be either a HTML string or a precompiled template.
* If it's a precompiled template, the passed in context will contain query and isEmpty.
*/
footer?: string;
footer?: any;
/**
* Rendered at the top of the dataset.
* Can be either a HTML string or a precompiled template.
* If it's a precompiled template, the passed in context will contain query and isEmpty.
*/
header?: string;
header?: any;
/**
* Used to render a single suggestion.