掲示板
Autocomplete - but only sometimes
12年前 に Brian Jamieson によって更新されました。
Autocomplete - but only sometimes
Junior Member 投稿: 51 参加年月日: 10/10/15 最新の投稿
Hi (again),
I'm trying to extend the functionality of my autocomplete picklist so that a user can type something that's NOT already in the list :
I think this can be done with this event handler:
I put the bold emphasis on. How can you 'select' something that doesn't match ? I figure 'select' means 'type' in this case.
My code is like so:
The problem is that the unmatchedItemSelect (!) doesn't seem to fire when you tab away from the input field.
Has anyone tried using autocomplete in this way ?
cheers,
Brian
I'm trying to extend the functionality of my autocomplete picklist so that a user can type something that's NOT already in the list :
I think this can be done with this event handler:
unmatchedItemSelect ( event )
Handles the unmatchedItemSelect event. Fired when a user selects something that does not match any of the displayed results.
I put the bold emphasis on. How can you 'select' something that doesn't match ? I figure 'select' means 'type' in this case.
My code is like so:
on: {
itemSelect: function(event) {
if (event !== null && event.details !== null && event.details[1] != null && event.details[1].key != null) {
alert("Hello @ itemSelect: " + event.details[1].name);
document.getElementById("<portlet:namespace />town").value = event.details[1].name;
}
},
unmatchedItemSelect: function(event) {
if (event !== null && event.details !== null && event.details[1] != null) {
alert("Hello @ unmatchedItem: " + event.details[1].name);
document.getElementById("<portlet:namespace />town").value = event.details[1].name;
}
},
textboxChange: function(event) {
if (document.getElementById("<portlet:namespace />_town_input").value == "") {
alert("Hello @ textboxchange: " + event.details[1].name);
document.getElementById("<portlet:namespace />town").value = "";
}
}
}
The problem is that the unmatchedItemSelect (!) doesn't seem to fire when you tab away from the input field.
Has anyone tried using autocomplete in this way ?
cheers,
Brian
12年前 に Brian Jamieson によって更新されました。
RE: Autocomplete - but only sometimes
Junior Member 投稿: 51 参加年月日: 10/10/15 最新の投稿
Solved it. It was my condition in the handler.
FYI:
FYI:
unmatchedItemSelect: function(event) {
[b]if (document.getElementById("<portlet:namespace />_town_input").value != "") {[/b]
alert("Hello @ unmatchedItem: " + document.getElementById("<portlet:namespace />_town_input").value);
document.getElementById("<portlet:namespace />town").value = document.getElementById("<portlet:namespace />_town_input").value;
}
}