-
Notifications
You must be signed in to change notification settings - Fork 122
Closed
Description
Hi;
I am using version 2.4.0. When i use an alert in obSubmit it is triggered twice if there is a result in the list so alert shown twice. If there is no result in the list it is ok and it is showing alert once.
Am i doing something wrong?
Here is my code
var originalQuery = '';
$('#sb').typeahead({
minLength: 2,
maxItem: 5,
hint: false,
highlight: true,
mustSelectItem: false,
emptyTemplate: "No Result",
display: ["title", "writer", "supporter", "owner", "target"],
template: "{{title}}, <small><em>{{author}}</em></small>",
backdrop: {
"background-color": "#333"
},
source: {
url: ["ProductList.json"],
dataType: "json"
},
callback: {
onClickBefore: function (node, a, item, event) {
// Save the query to be re-used in onClickAfter
originalQuery = this.query;
},
onClickAfter: function (node, query, item, event) {
event.preventDefault();
window.location = (item.target+'?q='+originalQuery);
},
onSubmit: function (node, form, item, event) {
alert('You should select an item in result');
return false;
},
},
debug: false
});