2015-11-17 39 views
1

即時通訊使用Semantic-UI爲我的網絡。我有數據表,每行都是刪除按鈕。點擊按鈕時,顯示模式。 Modal有兩個按鈕,取消或確認。當我點擊確認時,我想從數據庫中刪除行。但是,我如何檢測哪個按鈕被點擊?在HTML如何檢測點擊了哪個刪除按鈕?

表:

<tr> 
    <td>Name</td> 
    <td>  
     <button id='1' class="delete button"></button> 
    </td> 
</tr> 
<tr> 
    <td>Name2</td> 
    <td>  
     <button id='2' class="delete button"></button> 
    </td> 
</tr> 

當我在表中刪除按鈕點擊,顯示的JavaScript模式。 MODAL的Javascript

$('#removeAcredicationModal') 
       .modal({ 
        transition  : 'vertical flip', 
        mobileTransition : 'horizontal flip', 
        closable   : false, 
        approve   : '.submit, .approve', 
        deny    : '.cancel' 
        } 
       }) 
       .modal('attach events', '.delete', 'show') 
      ; 

HTML模式

<div id="removeAcredicationModal" class="ui small modal"> 
    <div class="ui approve submit green labeled icon button"> 
     <i class="checkmark icon"></i> 
     Delete 
    </div> 
    <div class="ui cancel red labeled icon button"> 
     <i class="remove icon"></i> 
     Cancel 
    </div> 
</div> 

在確認鍵單擊我想從DB

function doDelete(){ 
    var idOfRowToDelete = "??"; 
    //How to get the ID placed in table? 
    //Using controller, etc... 
}; 

任何想法如何刪除項目在toDelete功能從表中獲取ID?

回答