combobox issue
by mwagner72
HTML
<form class="simple_form form-stacked"><select class="select optional" id="event_data_request_id" name="event[data_request_id]" ><option value=""></option>
<option value="KS554a15d909163689af2347167480407bf3">new</option></select></form>
CSS
.clearfix {
zoom: 1; }
.clearfix:before, .clearfix:after {
display: table;
content: "";
zoom: 1; }
.clearfix:after {
clear: both; }
.fixed-container {
width: 940px;
margin-left: auto;
margin-right: auto;
zoom: 1; }
.fixed-container:before, .fixed-container:after {
display: table;
content: "";
zoom: 1; }
.fixed-container:after {
clear: both; }
html, body {
margin: 0;
padding: 0; }
h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, cite, code, del, dfn, em, img, q, s, samp, small, strike, strong, sub, sup, tt, var, dd, dl, dt, li, ol, ul, fieldset, form, label, legend, button, table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
line-height: 1;
font-family: inherit; }
table {
border-collapse: collapse;
border-spacing: 0; }
ol, ul {
list-style: none; }
q:before, q:after {
content: ""; }
blockquote:before, blockquote:after {
content: ""; }
html {
overflow-y: scroll;
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%; }
a:focus {
outline: 0; }
a:hover, a:active {
outline: 0; }
article, aside, details, figcaption, figure, footer, header, hgroup, nav, section {
display: block; }
audio, canvas, video {
display: inline-block;
*display: inline;
*zoom: 1; }
audio:not([controls]) {
display: none; }
sub {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline; }
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
top: -0.5em; }
sub {
bottom: -0.25em; }
img {
border: 0;
-ms-interpolation-mode: bicubic; }
button, input, select, textarea {
font-size: 100%;
margin: 0;
vertical-align: baseline;
*vertical-align: middle; }
button, input {
line-height: normal;
*overflow: visible; }
button::-moz-focus-inner, input::-moz-focus-inner {
border: 0;
padding: 0; }
button {
cursor:...
JavaScript
(function( $ ) {
$.widget( "ui.combobox", {
options: {
insert_add_entry: false,
add_prompt: "add",
precede_new_with: ''
},
_create: function() {
var self = this,
select = this.element.hide(),
selected = select.children( ":selected" ),
value = selected.val() ? selected.text() : "";
$(this.element).live('bbPop', function(e, data){
console.log('bbPop triggered');
$(input).val(data);
});
var input = this.input = $( "<input>" )
.insertAfter( select )
.val( value )
.autocomplete({
delay: 0,
minLength: 0,
source: function( request, response ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
selected_children =
select.children( "option" ).map(function() {
var text = $( this ).text();
if ( this.value && ( !request.term || matcher.test(text) ) )
return {
label: text.replace(
new RegExp(
"(?![^&;]+;)(?!<[^<>]*)(" +
$.ui.autocomplete.escapeRegex(request.term) +
")(?![^<>]*>)(?![^&;]+;)", "gi"
), "<strong>$1</strong>" ),
value: text,
option: this
};
})
returned_children = []
if (self.options.insert_add_entry) {
options = select.children("option").map(function() {
return $(this).text();
});
trimmed_user_entry = request.term.trim();
if (trimmed_user_entry != "" ) {
// look through options for exact match
found_match = false;
for (i = 0; i < options.length; i++) {
if (trimmed_user_entry == options[i] && trimmed_user_entry != "")
found_match = true;
...