javascript.stub 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. pk: '{%pk%}',
  20. sortName: '{%order%}',
  21. columns: [
  22. [
  23. {%javascriptList%}
  24. ]
  25. ]
  26. });
  27. {%headingJs%}
  28. // 为表格绑定事件
  29. Table.api.bindevent(table);
  30. },
  31. add: function () {
  32. Controller.api.bindevent();
  33. },
  34. edit: function () {
  35. Controller.api.bindevent();
  36. },
  37. api: {
  38. bindevent: function () {
  39. Form.api.bindevent($("form[role=form]"));
  40. }
  41. }
  42. };
  43. return Controller;
  44. });