我目前正在将此插件用于模态:http://awkward.github.io/backbone.modal/
它带有一个cancelEl
方法来关闭模态,我是这样使用它的:
var ActionModal = Backbone.Modal.extend({
template: '#actionable-modal-template',
cancelEl: '.bbm-btn-close'
});
这是我正在尝试做的,用伪代码编写:
if (cancelEl.invoked) {
// Do something
}
伪代码基于这样的假设:cancelEl
导致单击模态背景以及按钮以关闭模态。
如何使用cancelEl
方法?
谢谢。
最佳答案
你可以实现beforeCancel
或者cancel
var ActionModal = Backbone.Modal.extend({
template: '#actionable-modal-template',
cancelEl: '.bbm-btn-close',
beforeCancel: function() {
// stuff
}
});
查看源代码,beforeCancel
可用于取消模态关闭:
if (this.beforeCancel) {
if (this.beforeCancel() === false) {
return;
}
}
而cancel
可以用来实现更多的功能:
if (typeof this.cancel === "function") {
this.cancel();
}
关于javascript - 如何在 Backbone Modal 中使用 cancelEl?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36268625/