javascript.stub 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: '{%controllerUrl%}/index',
  8. add_url: '{%controllerUrl%}/add',
  9. edit_url: '{%controllerUrl%}/edit',
  10. del_url: '{%controllerUrl%}/del',
  11. multi_url: '{%controllerUrl%}/multi',
  12. table: '{%table%}',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. sortName: '{%order%}',
  20. columns: [
  21. [
  22. {%javascriptList%}
  23. ]
  24. ]
  25. });
  26. // 为表格绑定事件
  27. Table.api.bindevent(table);
  28. },
  29. add: function () {
  30. Controller.api.bindevent();
  31. },
  32. edit: function () {
  33. Controller.api.bindevent();
  34. },
  35. api: {
  36. bindevent: function () {
  37. Form.api.bindevent($("form[role=form]"));
  38. }
  39. }
  40. };
  41. return Controller;
  42. });