0
我創建了一個編輯下拉菜單,並使用下面的代碼來捕獲菜單外的點擊。點擊菜單外應該會觸發關閉功能。 注意:這是在mvc結構化應用程序中使用的。將點擊事件綁定到body IE8
所有的工作,直到我們到了IE8,它說「對象不支持屬性或方法。」 他們是否有任何創建此綁定的替代方法?
var that = this
$("body").on('click', that.outsideClickWatch.bind(that));
outsideClickWatch:function(e){
console.log("addOutsideClickWatch", this)
this.remove()
}
IE8不支持[Function.prototype.bind()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)。然而,在我鏈接的文章中有一個polyfill。 – 2014-11-05 10:48:25