Sha256: 6ec1da171b909cb1af2a60dfce6c32f85589ac9fea24bc8f90fea7952716eb7b
Contents?: true
Size: 1017 Bytes
Versions: 9
Compression:
Stored size: 1017 Bytes
Contents
(function( $ ){ $.fn.userSearch = function( options ) { // Create some defaults, extending them with any options that were provided var settings = $.extend( { }, options); var $container = this; return this.each(function() { $(this).select2( { placeholder: "Search for a user", minimumInputLength: 2, initSelection: function(element, callback) { }, ajax: { // instead of writing the function to execute the request we use Select2's convenient helper url: "/users.json", dataType: 'json', data: function (term, page) { return { uq: term // search term }; }, results: function (data, page) { // parse the results into the format expected by Select2. // since we are using custom formatting functions we do not need to alter remote JSON data return {results: data}; } }, }).select2('data', null); }); }; })( jQuery );
Version data entries
9 entries across 9 versions & 1 rubygems