|
@@ -443,6 +443,16 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
// TODO - replace query.page with query so users have access to term, page, etc.
|
|
// TODO - replace query.page with query so users have access to term, page, etc.
|
|
// added query as third paramter to keep backwards compatibility
|
|
// added query as third paramter to keep backwards compatibility
|
|
var results = options.results(data, query.page, query);
|
|
var results = options.results(data, query.page, query);
|
|
|
|
+ query.callback(results);
|
|
|
|
+ },
|
|
|
|
+ error: function(jqXHR, textStatus, errorThrown){
|
|
|
|
+ var results = {
|
|
|
|
+ hasError: true,
|
|
|
|
+ jqXHR: jqXHR,
|
|
|
|
+ textStatus: textStatus,
|
|
|
|
+ errorThrown: errorThrown,
|
|
|
|
+ };
|
|
|
|
+
|
|
query.callback(results);
|
|
query.callback(results);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -1766,6 +1776,12 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // handle ajax error
|
|
|
|
+ if(data.hasError !== undefined && checkFormatter(opts.formatAjaxError, "formatAjaxError")) {
|
|
|
|
+ render("<li class='select2-ajax-error'>" + evaluate(opts.formatAjaxError, opts.element, data.jqXHR, data.textStatus, data.errorThrown) + "</li>");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
// save context, if any
|
|
// save context, if any
|
|
this.context = (data.context===undefined) ? null : data.context;
|
|
this.context = (data.context===undefined) ? null : data.context;
|
|
// create a default choice and prepend it to the list
|
|
// create a default choice and prepend it to the list
|
|
@@ -3408,6 +3424,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
formatSelectionCssClass: function(data, container) {return undefined;},
|
|
formatSelectionCssClass: function(data, container) {return undefined;},
|
|
formatMatches: function (matches) { if (matches === 1) { return "One result is available, press enter to select it."; } return matches + " results are available, use up and down arrow keys to navigate."; },
|
|
formatMatches: function (matches) { if (matches === 1) { return "One result is available, press enter to select it."; } return matches + " results are available, use up and down arrow keys to navigate."; },
|
|
formatNoMatches: function () { return "No matches found"; },
|
|
formatNoMatches: function () { return "No matches found"; },
|
|
|
|
+ formatAjaxError: function (jqXHR, textStatus, errorThrown) { return "Loading failed"; },
|
|
formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1? "" : "s"); },
|
|
formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1? "" : "s"); },
|
|
formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1? "" : "s"); },
|
|
formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1? "" : "s"); },
|
|
formatSelectionTooBig: function (limit) { return "You can only select " + limit + " item" + (limit == 1 ? "" : "s"); },
|
|
formatSelectionTooBig: function (limit) { return "You can only select " + limit + " item" + (limit == 1 ? "" : "s"); },
|