I used the typeahead notFound 'template' option, from there i could set a link button which for me is more accesible. Typeahead settings:
$('#remote .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 2
},
{
name: 'sn-tags',
display: 'tag',
source: oBusqTags, //Bloodhound object
templates: {
notFound: '<p>No matches<br><a id="btnAddNewTag" href="#">Add New Tag</a></p>'
}
}).bind("typeahead:select", function(obj, datum, name) {
//add selection as an option on a select element
$('#lbxAddTag').append($('<option>', {
value: datum.id,
text: datum.tag
}));
});
This is the listener for that link:
$('#remote').on('click', '#btnAddNewTag', function(e){
$('#lbxAddTag').append($('<option>', {
value: "0",
// this is tricky, as there aren't any matches then
// $('#remote .typeahead').typeahead('val') contains '',
// so i had to set an id for the typeahead input text box and
// 'manually' get its value
text: $('#tbxBusqTag').val()
}));
// as the text is already added as a select option
// i clean the typeahead input box
$('#remote .typeahead').typeahead('val','');
e.preventDefault();
});