Created
August 4, 2014 18:59
-
-
Save petdance/15cb96eeb8fcb2a88638 to your computer and use it in GitHub Desktop.
Why is my autocomplete not populating the box I want?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="dropdown-container right" id="ccsstag_search_div"> | |
<span class="quiet strong">Find Tags by keyword: </span> | |
<input class="input-medium round" id="ccsstag_search" name="search-within" type="text" | |
style="background: url(/graphics/css/icon-lg-search.png) 6px 50% no-repeat; padding-left: 30px; margin-top: -9px;"> | |
<div class="dropdown-menu right inverse" style="margin-top: 2px; padding-top: 9px; padding-bottom: 6px;" /> | |
<div class="caret"><!-- --></div> | |
<div class="dropdown-content" style="width: 268px;" id="ccsstag_search_content"><!-- --></div> | |
</div> | |
</div> | |
<script> | |
require(['jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min-release-number'], function () { | |
var availableTags = [ | |
// list of tags eliminated | |
]; | |
var rlistid_lookup = { | |
// list of IDs eliminated | |
}; | |
var droppy = $( "#ccsstag_search" ).autocomplete({ | |
appendto: 'div.ccsstag_search_content', | |
source: availableTags, | |
delay: 0, | |
close: function() { | |
$('#ccsstag_search_div').removeClass('active'); | |
strval = $("#ccsstag_search").val(); | |
rlistid = rlistid_lookup[strval]; | |
if ( rlistid ) { | |
document.location = '/search?ccsstag_search=' + rlistid + '&SID=[% SID %]'; | |
} | |
return false; | |
}, | |
}); | |
droppy.data("autocomplete")._renderItem = function( ul, item ) { | |
return $( "<li>" ) | |
.append( "<a>" + item.label + "</a>" ) | |
.appendTo( ul ); | |
}; | |
droppy.data("autocomplete")._renderMenu = function( ul, items ) { | |
$('#ccsstag_search_div').addClass('active'); // Not sure this is the right place for this | |
var that = this; | |
$( ul ).addClass( 'nav-select' ); | |
$.each( items, function( index, item ) { | |
that._renderItem( ul, item ); | |
}); | |
//$( ul ).find( "li:odd" ).addClass( "strong" ); | |
}; | |
console.log("here's droppy"); | |
console.log(droppy); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment