media/js/vendor/selectize/selectize.js
function(value, data) {
			var self = this;
			var $item, $item_new;
			var value_new, index_item, cache_items, cache_options, order_old;
	
			value     = hash_key(value);
			value_new = hash_key(data[self.settings.valueField]);
	
			// sanity checks
			if (value === null) return;
			if (!self.options.hasOwnProperty(value)) return;
			if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
	
			order_old = self.options[value].$order;
	
			// update references
			if (value_new !== value) {
				delete self.options[value];
				index_item = self.items.indexOf(value);
				if (index_item !== -1) {
					self.items.splice(index_item, 1, value_new);
				}
			}
			data.$order = data.$order || order_old;
			self.options[value_new] = data;
	
			// invalidate render cache
			cache_items = self.renderCache['item'];
			cache_options = self.renderCache['option'];
	
			if (cache_items) {
				delete cache_items[value];
				delete cache_items[value_new];
			}
			if (cache_options) {
				delete cache_options[value];
				delete cache_options[value_new];
			}
	
			// update the item if it's selected
			if (self.items.indexOf(value_new) !== -1) {
				$item = self.getItem(value);
				$item_new = $(self.render('item', data));
				if ($item.hasClass('active')) $item_new.addClass('active');
				$item.replaceWith($item_new);
			}
	
			// invalidate last query because we might have updated the sortField
			self.lastQuery = null;
	
			// update dropdown contents
			if (self.isOpen) {
				self.refreshOptions(false);
			}
		}
function(value, data) {
			var self = this;
			var $item, $item_new;
			var value_new, index_item, cache_items, cache_options, order_old;
	
			value     = hash_key(value);
			value_new = hash_key(data[self.settings.valueField]);
	
			// sanity checks
			if (value === null) return;
			if (!self.options.hasOwnProperty(value)) return;
			if (typeof value_new !== 'string') throw new Error('Value must be set in option data');
	
			order_old = self.options[value].$order;
	
			// update references
			if (value_new !== value) {
				delete self.options[value];
				index_item = self.items.indexOf(value);
				if (index_item !== -1) {
					self.items.splice(index_item, 1, value_new);
				}
			}
			data.$order = data.$order || order_old;
			self.options[value_new] = data;
	
			// invalidate render cache
			cache_items = self.renderCache['item'];
			cache_options = self.renderCache['option'];
	
			if (cache_items) {
				delete cache_items[value];
				delete cache_items[value_new];
			}
			if (cache_options) {
				delete cache_options[value];
				delete cache_options[value_new];
			}
	
			// update the item if it's selected
			if (self.items.indexOf(value_new) !== -1) {
				$item = self.getItem(value);
				$item_new = $(self.render('item', data));
				if ($item.hasClass('active')) $item_new.addClass('active');
				$item.replaceWith($item_new);
			}
	
			// invalidate last query because we might have updated the sortField
			self.lastQuery = null;
	
			// update dropdown contents
			if (self.isOpen) {
				self.refreshOptions(false);
			}
		}
function ( value , data ) { var self = this ; var $item , $item_new ; var value_new , index_item , cache_items , cache_options , order_old ; value = hash_key ( value ) ; value_new = hash_key ( data [ self . settings . valueField ] ) ; // sanity checks if ( value === null ) return ; if ( ! self . options . hasOwnProperty ( value ) ) return ; if ( typeof value_new !== 'string' ) throw new Error ( 'Value must be set in option data' ) ; order_old = self . options [ value ] . $order ; // update references if ( value_new !== value ) { delete self . options [ value ] ; index_item = self . items . indexOf ( value ) ; if ( index_item !== - 1 ) { self . items . splice ( index_item , 1 , value_new ) ; } } data . $order = data . $order || order_old ; self . options [ value_new ] = data ; // invalidate render cache cache_items = self . renderCache [ 'item' ] ; cache_options = self . renderCache [ 'option' ] ; if ( cache_items ) { delete cache_items [ value ] ; delete cache_items [ value_new ] ; } if ( cache_options ) { delete cache_options [ value ] ; delete cache_options [ value_new ] ; } // update the item if it's selected if ( self . items . indexOf ( value_new ) !== - 1 ) { $item = self . getItem ( value ) ; $item_new = $ ( self . render ( 'item' , data ) ) ; if ( $item . hasClass ( 'active' ) ) $item_new . addClass ( 'active' ) ; $item . replaceWith ( $item_new ) ; } // invalidate last query because we might have updated the sortField self . lastQuery = null ; // update dropdown contents if ( self . isOpen ) { self . refreshOptions ( false ) ; } }
Updates an option available for selection. If
it is visible in the selected items or options
dropdown, it will be re-rendered automatically.

@param {string} value
@param {object} data
Updates an option available for selection . If it is visible in the selected items or options dropdown it will be re - rendered automatically .