我的问题是当我点击我的按钮时,它不会出现我的按钮点击,它会出现我的行点击(折叠事件)。
我这里有两个按钮,一个是用于打开模态,另一个有onclick事件,但它不工作。它是打开行折叠事件。
我的模态打开按钮是Cevapla。Sil按钮正在删除消息,但它只是折叠行下的面板
下面是我的html:
<tr class='accordion-toggle' onclick='UpdateIsRead(this);' style='cursor:pointer;background-color:{6}' data-toggle='collapse' data-target='#gelenRow{0}' data-isread='{5}'>
<td class='email-title'>{1}
</td>
<td class='email-body'>{2}
</td>
<td>{3}
</td>
<td>
<a class='modalButton btn btn-info btn-xs' data-height='550' title='Cevap Yaz' data-src='{7}apps/pages/PrivateMessage.aspx?topic={8}&toWho={9}' data-title='Cevap Yaz' data-headericoncolor='#000000' data-headercolor='#000000' data-icon='fa fa-envelope' data-toggle='modal' style='cursor: pointer' data-target='#popup' style='height:28px'><span class='fa fa-edit'></span> Cevapla</a>
<a style='height:28px' onclick='DeleteMessage();' title='Sil' class='btn btn-danger btn-xs'><span class='fa fa-remove'></span> Sil</a>
</td>
</tr>
<tr id='gelenRow{0}' class='collapse' style='background-color:#F5F5F5'>
<td colspan='6'>
<div class='panel-footer' style='padding: 10px 35px;'>
<div class='row'>
<div id='filter-panel' class='filter-panel'>
<div class='panel panel-default'>
<div class='panel-body'>
{4}
</div>
</div>
</div>
<button type='button' class='btn btn-sm btn-primary' >Cevap Yaz</button>
</div>
</div>
</td>
</tr>
我试着用这个代码:
$(document).on("click","tr", function(e){
if (e.target.nodeName == "A" || e.target.nodeName == "SPAN") {
e.parent().stopPropagation();
}
});
$(document).on("click","tr", function(e){
if (e.target.nodeName == "A" || e.target.nodeName == "SPAN") {
e.stopPropagation();
}
});
1条答案
按热度按时间y53ybaqx1#
Because your DeleteMessage & UpdateIsRead functions are inline in the HTML you can consider to pass the current element and event:
In this way you can add a test in your functions to stop propagation or action.
The event handlers order, clicking on DeleteMessage button is: