【问题标题】:Bootstrap Modal passing data through on('click-row.bs.table'Bootstrap Modal 通过 on('click-row.bs.table' 传递数据
【发布时间】:2016-07-20 11:59:43
【问题描述】:

我必须引导模态窗口...一个带有表格 (#items) 和另一个 (#item) 带有表单数据。

现在我想点击表格中的一行并想打开其他模态窗口并希望传递数据。

$('#items-table').on('click-row.bs.table', function (e, row, $element) {
    $('#items').modal('hide');
    $('#item').modal('show');
    //Need to pass row.id to #item
});

这是我从表格行中获得点击的地方。在这里,我得到了我想在我的#item 表单中使用的row.id

$('#item').on('shown.bs.modal', function (event) {
  var button = $(event.relatedTarget); // Button that triggered the modal
  var itemId = button.data('item-id') ;// Extract info from data-* attributes

})

站在那里的这两行来自一个具有 data- 属性的按钮。这工作正常,但我怎样才能从表中传递row.id

【问题讨论】:

标签: twitter-bootstrap bootstrap-modal bootstrap-table


【解决方案1】:

所以我想办法妥善处理:

    $('#items-table').on('click-row.bs.table', function (e, row, $element) {
    $('#items').modal('hide');
    $modal('#item');
    $modal.data('id', row.id);
    $modal.modal('show');
    //Need to pass row.id to #item
});

并在模态中捕获它,例如:

$('#item').on('shown.bs.modal', function (event) {

  var modal = $(this);
  var id = modal.data('id');

})

非常感谢 @wenyi 提供的链接!

【讨论】:

    猜你喜欢
    • 2016-01-07
    • 2016-03-27
    • 1970-01-01
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多