bootstrap-table-defer-url.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define([], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory();
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory();
  11. global.bootstrapTableDeferUrl = mod.exports;
  12. }
  13. })(this, function () {
  14. 'use strict';
  15. /**
  16. * When using server-side processing, the default mode of operation for
  17. * bootstrap-table is to simply throw away any data that currently exists in the
  18. * table and make a request to the server to get the first page of data to
  19. * display. This is fine for an empty table, but if you already have the first
  20. * page of data displayed in the plain HTML, it is a waste of resources. As
  21. * such, you can use data-defer-url instead of data-url to allow you to instruct
  22. * bootstrap-table to not make that initial request, rather it will use the data
  23. * already on the page.
  24. *
  25. * @author: Ruben Suarez
  26. * @webSite: http://rubensa.eu.org
  27. * @version: v1.0.0
  28. */
  29. (function ($) {
  30. 'use strict';
  31. $.extend($.fn.bootstrapTable.defaults, {
  32. deferUrl: undefined
  33. });
  34. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  35. _init = BootstrapTable.prototype.init;
  36. BootstrapTable.prototype.init = function () {
  37. _init.apply(this, Array.prototype.slice.apply(arguments));
  38. if (this.options.deferUrl) {
  39. this.options.url = this.options.deferUrl;
  40. }
  41. };
  42. })(jQuery);
  43. });