Skip to content

Commit 218bd47

Browse files
committed
Autocomplete combobox demo: Fixed styling of button. Fixed #8242 - Autocomplete combobox button has vertical offset relatively to input field (Opera 11.62). Fixed #8243 - Autocomplete combobox button has smaller height than input field (Firefox 11.0).
1 parent 9e9baad commit 218bd47

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

demos/autocomplete/combobox.html

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,37 @@
1414
<script src="../../ui/jquery.ui.tooltip.js"></script>
1515
<link rel="stylesheet" href="../demos.css">
1616
<style>
17+
.ui-combobox {
18+
position: relative;
19+
display: inline-block;
20+
}
1721
.ui-button {
22+
position: absolute;
23+
top: 0;
24+
bottom: 0;
1825
margin-left: -1px;
26+
padding: 0;
27+
/* adjust styles for IE 6/7 */
28+
*height: 1.7em;
29+
*top: 0.1em;
1930
}
20-
.ui-button-icon-only .ui-button-text {
21-
padding: 0.35em;
22-
}
2331
.ui-autocomplete-input {
2432
margin: 0;
25-
padding: 0.4em 0 0.4em 0.45em;
33+
padding: 0.3em;
2634
}
2735
</style>
2836
<script>
2937
(function( $ ) {
3038
$.widget( "ui.combobox", {
3139
_create: function() {
32-
var that = this,
40+
var input,
41+
that = this,
3342
select = this.element.hide(),
3443
selected = select.children( ":selected" ),
35-
value = selected.val() ? selected.text() : "";
44+
value = selected.val() ? selected.text() : "",
45+
wrapper = $( "<span>" )
46+
.addClass( "ui-combobox" )
47+
.insertAfter( select );
3648

3749
function removeIfInvalid(element) {
3850
var value = $( element ).val(),
@@ -59,10 +71,11 @@
5971
}
6072
}
6173

62-
var input = this.input = $( "<input>" )
63-
.insertAfter( select )
74+
input = $( "<input>" )
75+
.appendTo( wrapper )
6476
.val( value )
6577
.attr( "title", "" )
78+
.addClass( "ui-state-default" )
6679
.autocomplete({
6780
delay: 0,
6881
minLength: 0,
@@ -103,11 +116,11 @@
103116
.appendTo( ul );
104117
};
105118

106-
this.button = $( "<button type='button'>&nbsp;</button>" )
119+
$( "<a>" )
107120
.attr( "tabIndex", -1 )
108121
.attr( "title", "Show All Items" )
109122
.tooltip()
110-
.insertAfter( input )
123+
.appendTo( wrapper )
111124
.button({
112125
icons: {
113126
primary: "ui-icon-triangle-1-s"
@@ -142,8 +155,7 @@
142155
},
143156

144157
destroy: function() {
145-
this.input.remove();
146-
this.button.remove();
158+
this.wrapper.remove();
147159
this.element.show();
148160
$.Widget.prototype.destroy.call( this );
149161
}
@@ -159,7 +171,7 @@
159171
</script>
160172
</head>
161173
<body>
162-
174+
163175
<div class="demo">
164176

165177
<div class="ui-widget">

0 commit comments

Comments
 (0)