2014-06-12 10:27:26 +00:00
|
|
|
|
<script type="text/javascript">
|
2014-06-18 09:54:54 +00:00
|
|
|
|
var map = {},
|
|
|
|
|
members = [],
|
|
|
|
|
data = <%= raw @members_data %>;
|
|
|
|
|
$.each(data, function (i, member) {
|
|
|
|
|
map[member.memberName] = member;
|
|
|
|
|
members.push(member.memberName);
|
|
|
|
|
});
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
$('#member_autocomplete').typeahead({
|
2014-06-12 10:27:26 +00:00
|
|
|
|
source: function (query, process) {
|
2014-06-18 09:54:54 +00:00
|
|
|
|
return members;
|
|
|
|
|
},
|
|
|
|
|
updater: function (item) {
|
|
|
|
|
selectedMember = map[item].memberId;
|
|
|
|
|
$('#member_value').val(selectedMember);
|
|
|
|
|
return item;
|
|
|
|
|
},
|
|
|
|
|
matcher: function (item) {
|
|
|
|
|
if (item.toLowerCase().indexOf(this.query.trim().toLowerCase()) != -1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
sorter: function (items) {
|
|
|
|
|
return items.sort();
|
|
|
|
|
},
|
|
|
|
|
highlighter: function (item) {
|
|
|
|
|
var regex = new RegExp( '(' + this.query + ')', 'gi' );
|
|
|
|
|
return item.replace( regex, "<strong>$1</strong>" );
|
|
|
|
|
},
|
2014-06-12 10:27:26 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
</script>
|