Lines Matching refs:data

187             if ($.data(element, key) === undefined) {
188 $.data(element, key, element.val());
192 var val= $.data(element, key);
408 * @param options.url url for the data
409 * @param options.data a function(searchTerm, pageNumber, context) that should return an object containing query string parameters for the above url.
410 * @param options.dataType request data type: ajax, jsonp, other datatypes supported by jQuery's $.ajax function or the transport function if specified
412 * @param options.results a function(remoteData, pageNumber) that converts data returned form the remote request to the format expected by Select2.
428 var data = options.data, // ajax data function
440 data = data ? data.call(self, query.term, query.page, query.context) : null;
456 data: data,
457 success: function (data) {
459 var results = options.results(data, query.page);
476 * If the object form is used ti is assumed that it contains 'data' and 'text' keys. The 'data' key should contain
478 * key can either be a String in which case it is expected that each element in the 'data' array has a key with the
483 var data = options, // data elements
486 text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
488 if ($.isArray(data)) {
489 tmp = data;
490 data = { results: tmp };
493 if ($.isFunction(data) === false) {
494 tmp = data;
495 data = function() { return tmp; };
498 var dataItem = data();
503 dataText = dataItem.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available
511 query.callback(data());
535 $(data().results).each2(function(i, datum) { process(datum, filtered.results); });
541 function tags(data) {
542 var isFunc = $.isFunction(data);
545 $(isFunc ? data() : data).each(function () {
679 if (opts.element.data("select2") !== undefined &&
680 opts.element.data("select2") !== null) {
681 opts.element.data("select2").destroy();
710 .data("select2", this)
715 this.container.data("select2", this);
722 this.dropdown.data("select2", this);
817 var element=this.opts.element, select2 = element.data("select2");
850 locked: equal(element.attr("locked"), "locked") || equal(element.data("locked"), true)
874 $.each(["id", "multiple", "ajax", "query", "createSearchChoice", "initSelection", "data", "tags"], function () {
929 node.data("select2-data", result);
945 if ($.isArray(opts.element.data("select2Tags"))) {
947 throw "tags specified as both an attribute 'data-select2-tags' and in options of Select2 " + opts.element.attr("id");
949 opts.tags=opts.element.data("select2Tags");
954 var data = { results: [], more: false },
983 children.each2(function(i, elm) { process(elm, data.results); });
985 query.callback(data);
993 ajaxUrl = opts.element.data("ajax-url");
998 } else if ("data" in opts) {
999 opts.query = local(opts.data);
1007 var data = [];
1013 data.push(obj);
1016 callback(data);
1047 if (this.opts.element.data("select2-change-triggered") !== true) {
1091 triggerSelect: function(data) {
1092 var evt = $.Event("select2-selecting", { val: this.id(data), object: data });
1106 this.opts.element.data("select2-change-triggered", true);
1108 this.opts.element.data("select2-change-triggered", false);
1343 self=dropdown.data("select2");
1498 data;
1519 data = choice.data("select2-data");
1520 if (data) {
1521 this.opts.element.trigger({ type: "select2-highlight", val: this.id(data), choice: data });
1575 callback: this.bind(function (data) {
1581 self.opts.populateResults.call(this, results, data.results, {term: term, page: page, context:context});
1582 self.postprocessResults(data, false, false);
1584 if (data.more===true) {
1592 self.context = data.context;
1593 this.opts.element.trigger({ type: "select2-loaded", items: data });
1613 data,
1617 lastTerm = $.data(this.container, "select2-last-term"),
1624 $.data(this.container, "select2-last-term", term);
1651 data = this.data();
1652 if ($.isArray(data) && data.length >= maxSelSize && checkFormatter(opts.formatSelectionTooBig, "formatSelectionTooBig")) {
1699 callback: this.bind(function (data) {
1714 this.context = (data.context===undefined) ? null : data.context;
1717 def = this.opts.createSearchChoice.call(self, search.val(), data.results);
1719 if ($(data.results).filter(
1723 this.opts.createSearchChoicePosition(data.results, def);
1728 if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) {
1734 self.opts.populateResults.call(this, results, data.results, {term: search.val(), page: this.resultsPage, context:null});
1736 if (data.more === true && checkFormatter(opts.formatLoadMore, "formatLoadMore")) {
1741 this.postprocessResults(data, initial);
1745 this.opts.element.trigger({ type: "select2-loaded", items: data });
1781 data = highlighted.closest('.select2-result').data("select2-data");
1783 if (data) {
1785 this.onSelect(data, options);
1795 this.opts.element.attr("data-placeholder") || // jquery 1.4 compat
1796 this.opts.element.data("placeholder") ||
2177 var data=this.selection.data("select2-data");
2178 if (data) { // guard against queued quick consecutive clicks
2187 this.selection.removeData("select2-data");
2191 this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
2192 this.triggerChange({removed:data});
2241 } else if ("data" in opts) {
2242 // install default initSelection when applied to hidden input and data is local
2245 //search in data by id, storing the actual matching item
2295 postprocessResults: function (data, initial, noHighlightUpdate) {
2301 if (equal(self.id(elm.data("select2-data")), self.opts.element.val())) {
2321 this.showSearch(countResults(data.results) >= min);
2339 onSelect: function (data, options) {
2341 if (!this.triggerSelect(data)) { return; }
2344 oldData = this.data();
2346 this.opts.element.val(this.id(data));
2347 this.updateSelection(data);
2349 this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });
2351 this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
2358 if (!equal(old, this.id(data))) {
2359 this.triggerChange({ added: data, removed: oldData });
2364 updateSelection: function (data) {
2368 this.selection.data("select2-data", data);
2371 if (data !== null) {
2372 formatted=this.opts.formatSelection(data, container, this.opts.escapeMarkup);
2377 cssClass=this.opts.formatSelectionCssClass(data, container);
2393 data = null,
2395 oldData = this.data();
2411 data = self.optionToData(elm);
2414 this.updateSelection(data);
2417 this.triggerChange({added: data, removed:oldData});
2429 this.opts.initSelection(this.opts.element, function(data){
2430 self.opts.element.val(!data ? "" : self.id(data));
2431 self.updateSelection(data);
2434 self.triggerChange({added: data, removed:oldData});
2447 data: function(value) {
2448 var data,
2452 data = this.selection.data("select2-data");
2453 if (data == undefined) data = null;
2454 return data;
2462 data = this.data();
2466 this.triggerChange({added: value, removed:data});
2504 var data = [];
2507 data.push(self.optionToData(elm));
2509 callback(data);
2511 } else if ("data" in opts) {
2512 // install default initSelection when applied to hidden input and data is local
2515 //search in data by array of ids, storing matching items in a list
2529 // they are in the order in which they appear in data array
2763 var data;
2772 this.opts.initSelection.call(null, this.opts.element, function(data){
2773 if (data !== undefined && data !== null) {
2774 self.updateSelection(data);
2846 updateSelection: function (data) {
2850 $(data).each(function () {
2856 data = filtered;
2859 $(data).each(function () {
2868 input = this.opts.tokenizer.call(this, input, this.data(), this.bind(this.onSelect), this.opts);
2879 onSelect: function (data, options) {
2881 if (!this.triggerSelect(data)) { return; }
2883 this.addSelectedChoice(data);
2885 this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
2888 this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val());
2893 if (this.select || !this.opts.closeOnSelect) this.postprocessResults(data, false, this.opts.closeOnSelect===true);
2924 this.triggerChange({ added: data });
2936 addSelectedChoice: function (data) {
2937 var enableChoice = !data.locked,
2948 id = this.id(data),
2953 formatted=this.opts.formatSelection(data, choice.find("div"), this.opts.escapeMarkup);
2957 cssClass=this.opts.formatSelectionCssClass(data, choice.find("div"));
2980 choice.data("select2-data", data);
2990 data,
2998 data = selected.data("select2-data");
3000 if (!data) {
3007 evt.val = this.id(data);
3008 evt.choice = data;
3015 while((index = indexOf(this.id(data), val)) >= 0) {
3023 this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
3024 this.triggerChange({ removed: data });
3030 postprocessResults: function (data, initial, noHighlightUpdate) {
3037 var id = self.id(choice.data("select2-data"));
3059 if(!data || data && !data.more && this.results.find(".select2-no-results").length === 0) {
3160 oldData=this.data();
3169 this.triggerChange({added: this.data(), removed: oldData});
3180 this.triggerChange(this.buildChangeDetails(oldData, this.data()));
3187 this.opts.initSelection(this.opts.element, function(data){
3188 var ids=$.map(data, self.id);
3190 self.updateSelection(data);
3193 self.triggerChange(self.buildChangeDetails(oldData, self.data()));
3226 val.push(self.opts.id($(this).data("select2-data")));
3233 data: function(values, triggerChange) {
3238 .map(function() { return $(this).data("select2-data"); })
3241 old = this.data();
3248 this.triggerChange(this.buildChangeDetails(old, this.data()));
3260 allowedMethods = ["val", "destroy", "opened", "open", "close", "focus", "isFocused", "container", "dropdown", "onSortStart", "onSortEnd", "enable", "disable", "readonly", "positionDropdown", "data", "search"],
3262 propertyMethods = ["val", "data"],
3286 select2 = $(this).data("select2");
3326 formatSelection: function (data, container, escapeMarkup) {
3327 return data ? escapeMarkup(data.text) : undefined;
3332 formatResultCssClass: function(data) {return data.css;},
3333 formatSelectionCssClass: function(data, container) {return undefined;},