Blogger Information
Blog 20
fans 1
comment 1
visits 30506
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
fastadmin 上面添加按钮 并且按钮上的URL可以获取当前地址
大瓶可乐
Original
2280 people have browsed it


首先是按钮代码

  1. {
  2. field: 'buttons',
  3. width: "120px",
  4. title: __('添加内容'),
  5. table: table,
  6. events: Table.api.events.operate,
  7. buttons: [
  8. {
  9. name: 'detail',
  10. text: __('添加内容'),
  11. title: __('添加内容'),
  12. extend:'data-area=["80%","80%"]',
  13. classname: 'btn btn-xs btn-primary btn-dialog',
  14. icon: 'fa fa-list',
  15. url: '',//如果你不需要传参直接在这个里写URL就可以
  16. callback: function (data) {
  17. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  18. },
  19. visible: function (row) {
  20. //返回true时按钮显示,返回false隐藏
  21. return true;
  22. }
  23. },
  24. ],
  25. formatter: Table.api.formatter.buttons
  26. },

这个时候因为我需要把当前行的ID传给要跳转层的内容里,所以我加了一个获取当前ID并且赋值给按钮的js。

  1. $(document).on('mouseenter', '.btn-dialog', function (e) {
  2. var that = this;
  3. var options = $.extend({}, $(that).data() || {});
  4. var row = {};
  5. if (typeof options.tableId !== 'undefined') {
  6. var index = parseInt(options.rowIndex);
  7. var data = $("#" + options.tableId).bootstrapTable('getData');
  8. row = typeof data[index] !== 'undefined' ? data[index] : {};
  9. }
  10. $(this).attr('href','game/download/add?dialog=1&dig_id='+row.id);
  11. })

这样子就大功告成了

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post