簡體   English   中英

骨干模態-正確的方法

[英]Backbone Modals - proper approach

我使用所有模型都通用的模型和模態,我想知道什么是處理刪除模型ID的正確方法,我的想法是:

在刪除鏈接上觸發模型中的功能:

modal : function(e) {
    var edu_id = $(e.currentTarget).data('id'),
        confirm = $(e.currentTarget).data('confirm');
        newModal = new Modal({ model: new Backbone.Model({header:"Potwierdź", content: confirm}) });

    // we are waiting for OK button in modal, when event occured FIRE!
    newModal.on('fire',this.fire,this);
    e.preventDefault();
}

我正在監聽用戶單擊“確定”按鈕時觸發的“起火”事件,主要問題是如何通過edu_id刪除元素? 那是一般的好方法還是我應該以其他方式做到這一點。

對自己說:),我是怎么做到的,只是在帶有附加參數的子事件中觸發事件:

this.trigger('fire',model_id);

而且效果很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM