aboutsummaryrefslogtreecommitdiffstats
path: root/demos/autocomplete/combobox.html
diff options
context:
space:
mode:
authormaggiewachs <maggie@filamentgroup.com>2010-04-16 14:24:49 -0400
committermaggiewachs <maggie@filamentgroup.com>2010-04-16 14:24:49 -0400
commit970ed9a67a533ab44b184babf52100dfbcfa7c96 (patch)
tree423aa90362d991c62af87ec7b1a094706f46cdcd /demos/autocomplete/combobox.html
parent4ffe07457cb21332e9a33c319c1f1f610e532a27 (diff)
parentd1033cc2b79067f31767bfe0bb1f9a761dae9b3f (diff)
downloadjquery-ui-970ed9a67a533ab44b184babf52100dfbcfa7c96.tar.gz
jquery-ui-970ed9a67a533ab44b184babf52100dfbcfa7c96.zip
Merge branch 'master' of github.com:jquery/jquery-ui
Diffstat (limited to 'demos/autocomplete/combobox.html')
-rw-r--r--demos/autocomplete/combobox.html21
1 files changed, 13 insertions, 8 deletions
diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html
index e5dc6c92b..3001f7d17 100644
--- a/demos/autocomplete/combobox.html
+++ b/demos/autocomplete/combobox.html
@@ -30,24 +30,23 @@
var matcher = new RegExp(request.term, "i");
response(select.children("option").map(function() {
var text = $(this).text();
- if (!request.term || matcher.test(text))
+ if (this.value && (!request.term || matcher.test(text)))
return {
- id: $(this).val(),
- label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + request.term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
+ id: this.value,
+ label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
value: text
};
}));
},
delay: 0,
- select: function(e, ui) {
+ change: function(event, ui) {
if (!ui.item) {
// remove invalid value, as it didn't match anything
$(this).val("");
return false;
}
- $(this).focus();
select.val(ui.item.id);
- self._trigger("selected", null, {
+ self._trigger("selected", event, {
item: select.find("[value='" + ui.item.id + "']")
});
@@ -56,6 +55,7 @@
})
.addClass("ui-widget ui-widget-content ui-corner-left");
$("<button>&nbsp;</button>")
+ .attr("tabIndex", -1)
.attr("title", "Show All Items")
.insertAfter(input)
.button({
@@ -81,7 +81,10 @@
})(jQuery);
$(function() {
- $("select").combobox();
+ $("#combobox").combobox();
+ $("#toggle").click(function() {
+ $("#combobox").toggle();
+ });
});
</script>
</head>
@@ -91,7 +94,8 @@
<div class="ui-widget">
<label>Your preferred programming language: </label>
- <select>
+ <select id="combobox">
+ <option value="">Select one...</option>
<option value="a">asp</option>
<option value="c">c</option>
<option value="cpp">c++</option>
@@ -107,6 +111,7 @@
<option value="s">scala</option>
</select>
</div>
+<button id="toggle">Show underlying select</button>
</div><!-- End demo -->