function(triggerDropdown) {
		var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
		var $active, $active_before, $create;

		if (typeof triggerDropdown === 'undefined') {
			triggerDropdown = true;
		}

		var self              = this;
		var query             = $.trim(self.$control_input.val());
		var results           = self.search(query);
		var $dropdown_content = self.$dropdown_content;
		var active_before     = self.$activeOption && hash_key(self.$activeOption.attr('data-value'));

		// build markup
		n = results.items.length;
		if (typeof self.settings.maxOptions === 'number') {
			n = Math.min(n, self.settings.maxOptions);
		}

		// render and group available options individually
		groups = {};
		groups_order = [];

		for (i = 0; i < n; i++) {
			option      = self.options[results.items[i].id];
			option_html = self.render('option', option);
			optgroup    = option[self.settings.optgroupField] || '';
			optgroups   = $.isArray(optgroup) ? optgroup : [optgroup];

			for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
				optgroup = optgroups[j];
				if (!self.optgroups.hasOwnProperty(optgroup)) {
					optgroup = '';
				}
				if (!groups.hasOwnProperty(optgroup)) {
					groups[optgroup] = document.createDocumentFragment();
					groups_order.push(optgroup);
				}
				groups[optgroup].appendChild(option_html);
			}
		}

		// sort optgroups
		if (this.settings.lockOptgroupOrder) {
			groups_order.sort(function(a, b) {
				var a_order = self.optgroups[a].$order || 0;
				var b_order = self.optgroups[b].$order || 0;
				return a_order - b_order;
			});
		}

		// render optgroup headers & join groups
		html = document.createDocumentFragment();
		for (i = 0, n = groups_order.length; i < n; i++) {
			optgroup = groups_order[i];
			if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].childNodes.length) {
				// render the optgroup header and options within it,
				// then pass it to the wrapper template
				html_children = document.createDocumentFragment();
				html_children.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
				html_children.appendChild(groups[optgroup]);

				html.appendChild(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
					html: domToString(html_children),
					dom:  html_children
				})));
			} else {
				html.appendChild(groups[optgroup]);
			}
		}

		$dropdown_content.html(html);

		// highlight matching terms inline
		if (self.settings.highlight) {
			$dropdown_content.removeHighlight();
			if (results.query.length && results.tokens.length) {
				for (i = 0, n = results.tokens.length; i < n; i++) {
					highlight($dropdown_content, results.tokens[i].regex);
				}
			}
		}

		// add "selected" class to selected options
		if (!self.settings.hideSelected) {
			for (i = 0, n = self.items.length; i < n; i++) {
				self.getOption(self.items[i]).addClass('selected');
			}
		}

		// add create option
		has_create_option = self.canCreate(query);
		if (has_create_option) {
			$dropdown_content.prepend(self.render('option_create', {input: query}));
			$create = $($dropdown_content[0].childNodes[0]);
		}

		// activate
		self.hasOptions = results.items.length > 0 || has_create_option;
		if (self.hasOptions) {
			if (results.items.length > 0) {
				$active_before = active_before && self.getOption(active_before);
				if ($active_before && $active_before.length) {
					$active = $active_before;
				} else if (self.settings.mode === 'single' && self.items.length) {
					$active = self.getOption(self.items[0]);
				}
				if (!$active || !$active.length) {
					if ($create && !self.settings.addPrecedence) {
						$active = self.getAdjacentOption($create, 1);
					} else {
						$active = $dropdown_content.find('[data-selectable]:first');
					}
				}
			} else {
				$active = $create;
			}
			self.setActiveOption($active);
			if (triggerDropdown && !self.isOpen) { self.open(); }
		} else {
			self.setActiveOption(null);
			if (triggerDropdown && self.isOpen) { self.close(); }
		}
	}
function(triggerDropdown) {
		var i, j, k, n, groups, groups_order, option, option_html, optgroup, optgroups, html, html_children, has_create_option;
		var $active, $active_before, $create;

		if (typeof triggerDropdown === 'undefined') {
			triggerDropdown = true;
		}

		var self              = this;
		var query             = $.trim(self.$control_input.val());
		var results           = self.search(query);
		var $dropdown_content = self.$dropdown_content;
		var active_before     = self.$activeOption && hash_key(self.$activeOption.attr('data-value'));

		
		n = results.items.length;
		if (typeof self.settings.maxOptions === 'number') {
			n = Math.min(n, self.settings.maxOptions);
		}

		
		groups = {};
		groups_order = [];

		for (i = 0; i < n; i++) {
			option      = self.options[results.items[i].id];
			option_html = self.render('option', option);
			optgroup    = option[self.settings.optgroupField] || '';
			optgroups   = $.isArray(optgroup) ? optgroup : [optgroup];

			for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
				optgroup = optgroups[j];
				if (!self.optgroups.hasOwnProperty(optgroup)) {
					optgroup = '';
				}
				if (!groups.hasOwnProperty(optgroup)) {
					groups[optgroup] = document.createDocumentFragment();
					groups_order.push(optgroup);
				}
				groups[optgroup].appendChild(option_html);
			}
		}

		
		if (this.settings.lockOptgroupOrder) {
			groups_order.sort(function(a, b) {
				var a_order = self.optgroups[a].$order || 0;
				var b_order = self.optgroups[b].$order || 0;
				return a_order - b_order;
			});
		}

		
		html = document.createDocumentFragment();
		for (i = 0, n = groups_order.length; i < n; i++) {
			optgroup = groups_order[i];
			if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].childNodes.length) {
				
				
				html_children = document.createDocumentFragment();
				html_children.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
				html_children.appendChild(groups[optgroup]);

				html.appendChild(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
					html: domToString(html_children),
					dom:  html_children
				})));
			} else {
				html.appendChild(groups[optgroup]);
			}
		}

		$dropdown_content.html(html);

		
		if (self.settings.highlight) {
			$dropdown_content.removeHighlight();
			if (results.query.length && results.tokens.length) {
				for (i = 0, n = results.tokens.length; i < n; i++) {
					highlight($dropdown_content, results.tokens[i].regex);
				}
			}
		}

		
		if (!self.settings.hideSelected) {
			for (i = 0, n = self.items.length; i < n; i++) {
				self.getOption(self.items[i]).addClass('selected');
			}
		}

		
		has_create_option = self.canCreate(query);
		if (has_create_option) {
			$dropdown_content.prepend(self.render('option_create', {input: query}));
			$create = $($dropdown_content[0].childNodes[0]);
		}

		
		self.hasOptions = results.items.length > 0 || has_create_option;
		if (self.hasOptions) {
			if (results.items.length > 0) {
				$active_before = active_before && self.getOption(active_before);
				if ($active_before && $active_before.length) {
					$active = $active_before;
				} else if (self.settings.mode === 'single' && self.items.length) {
					$active = self.getOption(self.items[0]);
				}
				if (!$active || !$active.length) {
					if ($create && !self.settings.addPrecedence) {
						$active = self.getAdjacentOption($create, 1);
					} else {
						$active = $dropdown_content.find('[data-selectable]:first');
					}
				}
			} else {
				$active = $create;
			}
			self.setActiveOption($active);
			if (triggerDropdown && !self.isOpen) { self.open(); }
		} else {
			self.setActiveOption(null);
			if (triggerDropdown && self.isOpen) { self.close(); }
		}
	}
function ( triggerDropdown ) { var i , j , k , n , groups , groups_order , option , option_html , optgroup , optgroups , html , html_children , has_create_option ; var $active , $active_before , $create ; if ( typeof triggerDropdown === 'undefined' ) { triggerDropdown = true ; } var self = this ; var query = $ . trim ( self . $control_input . val ( ) ) ; var results = self . search ( query ) ; var $dropdown_content = self . $dropdown_content ; var active_before = self . $activeOption && hash_key ( self . $activeOption . attr ( 'data-value' ) ) ; // build markup n = results . items . length ; if ( typeof self . settings . maxOptions === 'number' ) { n = Math . min ( n , self . settings . maxOptions ) ; } // render and group available options individually groups = { } ; groups_order = [ ] ; for ( i = 0 ; i < n ; i ++ ) { option = self . options [ results . items [ i ] . id ] ; option_html = self . render ( 'option' , option ) ; optgroup = option [ self . settings . optgroupField ] || '' ; optgroups = $ . isArray ( optgroup ) ? optgroup : [ optgroup ] ; for ( j = 0 , k = optgroups && optgroups . length ; j < k ; j ++ ) { optgroup = optgroups [ j ] ; if ( ! self . optgroups . hasOwnProperty ( optgroup ) ) { optgroup = '' ; } if ( ! groups . hasOwnProperty ( optgroup ) ) { groups [ optgroup ] = document . createDocumentFragment ( ) ; groups_order . push ( optgroup ) ; } groups [ optgroup ] . appendChild ( option_html ) ; } } // sort optgroups if ( this . settings . lockOptgroupOrder ) { groups_order . sort ( function ( a , b ) { var a_order = self . optgroups [ a ] . $order || 0 ; var b_order = self . optgroups [ b ] . $order || 0 ; return a_order - b_order ; } ) ; } // render optgroup headers & join groups html = document . createDocumentFragment ( ) ; for ( i = 0 , n = groups_order . length ; i < n ; i ++ ) { optgroup = groups_order [ i ] ; if ( self . optgroups . hasOwnProperty ( optgroup ) && groups [ optgroup ] . childNodes . length ) { // render the optgroup header and options within it, // then pass it to the wrapper template html_children = document . createDocumentFragment ( ) ; html_children . appendChild ( self . render ( 'optgroup_header' , self . optgroups [ optgroup ] ) ) ; html_children . appendChild ( groups [ optgroup ] ) ; html . appendChild ( self . render ( 'optgroup' , $ . extend ( { } , self . optgroups [ optgroup ] , { html : domToString ( html_children ) , dom : html_children } ) ) ) ; } else { html . appendChild ( groups [ optgroup ] ) ; } } $dropdown_content . html ( html ) ; // highlight matching terms inline if ( self . settings . highlight ) { $dropdown_content . removeHighlight ( ) ; if ( results . query . length && results . tokens . length ) { for ( i = 0 , n = results . tokens . length ; i < n ; i ++ ) { highlight ( $dropdown_content , results . tokens [ i ] . regex ) ; } } } // add "selected" class to selected options if ( ! self . settings . hideSelected ) { for ( i = 0 , n = self . items . length ; i < n ; i ++ ) { self . getOption ( self . items [ i ] ) . addClass ( 'selected' ) ; } } // add create option has_create_option = self . canCreate ( query ) ; if ( has_create_option ) { $dropdown_content . prepend ( self . render ( 'option_create' , { input : query } ) ) ; $create = $ ( $dropdown_content [ 0 ] . childNodes [ 0 ] ) ; } // activate self . hasOptions = results . items . length > 0 || has_create_option ; if ( self . hasOptions ) { if ( results . items . length > 0 ) { $active_before = active_before && self . getOption ( active_before ) ; if ( $active_before && $active_before . length ) { $active = $active_before ; } else if ( self . settings . mode === 'single' && self . items . length ) { $active = self . getOption ( self . items [ 0 ] ) ; } if ( ! $active || ! $active . length ) { if ( $create && ! self . settings . addPrecedence ) { $active = self . getAdjacentOption ( $create , 1 ) ; } else { $active = $dropdown_content . find ( '[data-selectable]:first' ) ; } } } else { $active = $create ; } self . setActiveOption ( $active ) ; if ( triggerDropdown && ! self . isOpen ) { self . open ( ) ; } } else { self . setActiveOption ( null ) ; if ( triggerDropdown && self . isOpen ) { self . close ( ) ; } } }
Refreshes the list of available options shown
in the autocomplete dropdown menu.

@param {boolean} triggerDropdown
Refreshes the list of available options shown in the autocomplete dropdown menu .