【问题标题】:Materialize modal ignore trigger物化模态忽略触发器
【发布时间】:2020-12-02 10:47:28
【问题描述】:

我有一个包含子节点的表格单元格。当用户单击表格单元格而不是该特定子节点时,我想打开一个模式。:

<td class="modal-trigger" data-target="my_modal"> Open <i class="material-icons arrow_drop_down" aria-hidden="true">arrow_drop_down</i></td>
<div class="modal" id="set_metadata">
...
</div>

当用户单击 td 上的任何位置时,模式应该打开,但在单击箭头时不会打开(它用于折叠表格行)。在我尝试的js代码中:

$(elem).on("click", (e) => {
  if (e.target !== this)
    return;
  { do something }
});

但这并不妨碍打开模式。 materialize 中是否有一个函数告诉忽略触发器?

【问题讨论】:

    标签: javascript html jquery materialize


    【解决方案1】:

    这应该可行。试试看。

    此代码只响应点击标签td

    $('.modal-trigger').click(function () {
        /* here's the code for the tag "td" */
    }).on('click', '.material-icons.arrow_drop_down', function(){
        return false;
        console.log('this message should not be');
    });
    

    此代码用于点击i 标签。

    $('.material-icons.arrow_drop_down').click(function () {
        /* here's the code for the tag "i" */
    });
    

    【讨论】:

    • 它不起作用。可能是因为模态打开是通过物化完成的。我将删除模态触发器类并使用.show() 打开它。感谢您的宝贵时间!
    猜你喜欢
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    • 2011-02-14
    • 2010-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    相关资源
    最近更新 更多