我试图将几个函数绑定到单击事件。我要说的是:
var Foreground = Backbone.Marionette.Layout.extend({
el: $('body'),
events: {
'click': 'tryResetContextMenu onClickDeselectCollections'
},
// Whenever the user clicks on any part of the UI that isn't a multi-select item, deselect the multi-select items.
onClickDeselectCollections: function (event) {
console.log("deselect collections");
var isMultiSelectItem = $(event.target).hasClass('multiSelectItem');
var isChildMultiSelectItem = $(event.target).closest('.multiSelectItem').length > 0;
if (!isMultiSelectItem && !isChildMultiSelectItem) {
this.deselectCollections();
}
},
// If a click occurs and the default isn't prevented, reset the context menu groups to hide it.
// Child elements will call event.preventDefault() to indicate that they have handled the context menu.
tryResetContextMenu: function (event) {
console.log("resetting context menu items");
if (event.isDefaultPrevented()) {
// TODO: I don't think this is the proper way to do this. I should be showing a new view with top/left defined?
this.contextMenu.currentView.show({
top: event.pageY,
// Show the element just slightly offset as to not break onHover effects.
left: event.pageX + 1
});
} else {
// Clearing the groups of the context menu will cause it to become hidden.
ContextMenuItems.reset();
}
}
});这两种功能都不启动,但单独工作很好。支持此功能吗?
发布于 2014-02-18 18:04:57
就像这样:
events: {
'click': function(event) {
this.tryResetContextMenu(event);
this.onClickDeselectCollections(event);
}
},https://stackoverflow.com/questions/21861789
复制相似问题