Last active
December 20, 2015 04:08
-
-
Save jharding/6068247 to your computer and use it in GitHub Desktop.
I'm trying to work out the new typeahead.js API for v0.10 and I'm looking for some feedback. The issue is that due to the amount of flexibility added in v0.10, designing a clean, intuitive API is proving to be a challenge. This gist contains 2 possible APIs I've been kicking around. I'm not really a big fan of either of them so if you have any i…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple | |
// ------ | |
$('.typeahead').typeahead({ | |
autoselect: true, | |
hightlight: true, | |
hint: true | |
}).typeahead('add', { | |
name: 'films', | |
source: { | |
remote: '/films?q=%QUERY' | |
}, | |
templates: { | |
suggestion: suggestionTemplate | |
} | |
}); | |
// complex | |
// ------- | |
$('.typeahead').typeahead({ | |
autoselect: true, | |
hightlight: true, | |
hint: true | |
}).typeahead('add', { | |
name: 'presidents', | |
source: { | |
local: ['George Washington', 'John Adams'], | |
remote: '/presidents?q=%QUERY' | |
}, | |
templates: { | |
suggestion: suggestionTemplate, | |
empty: emptyTemplate | |
} | |
}, | |
{ | |
name: 'basketball-players', | |
source: { | |
local: ['Ben Wallace', 'Rasheed Wallace'], | |
remote: '/bball?q=%QUERY' | |
}, | |
templates: { | |
suggestion: suggestionTemplate, | |
empty: emptyTemplate | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple | |
// ------ | |
$('.typeahead').typeahead({ | |
autoselect: true, | |
hightlight: true, | |
hint: true | |
sections: { | |
name: 'films', | |
source: { | |
remote: '/films?q=%QUERY' | |
}, | |
templates: { | |
suggestion: suggestionTemplate | |
} | |
} | |
}); | |
// complex | |
// ------- | |
$('.typeahead').typeahead({ | |
autoselect: true, | |
hightlight: true, | |
hint: true, | |
sections: [ | |
{ | |
name: 'presidents', | |
source: { | |
local: ['George Washington', 'John Adams'], | |
remote: '/presidents?q=%QUERY' | |
}, | |
templates: { | |
suggestion: suggestionTemplate, | |
empty: emptyTemplate | |
} | |
}, | |
{ | |
name: 'basketball-players', | |
source: { | |
local: ['Ben Wallace', 'Rasheed Wallace'], | |
remote: '/bball?q=%QUERY' | |
}, | |
templates: { | |
suggestion: suggestionTemplate, | |
empty: emptyTemplate | |
} | |
} | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you send how do typehead.js full code .
index.html
file name.json
and *.js file