notification_dropdown_view.js:試圖隱藏下拉骨幹錯誤
initialize: function(){
$(document.body).click($.proxy(this.hideDropdown, this));
this.notifications = [];
this.perPage = 5;
this.hasMoreNotifs = true;
this.badge = this.$el;
this.dropdown = $("#notification-dropdown");
this.dropdownNotifications = this.dropdown.find(".notifications");
this.ajaxLoader = this.dropdown.find(".ajax_loader");
this.perfectScrollbarInitialized = false;
},
hideDropdown: function(evt){
var inDropdown = $(evt.target).parents().is($(".dropdown-menu", this.dropdown));
var inHovercard = $.contains(app.hovercard.el, evt.target);
if(!inDropdown && !inHovercard && this.dropdownShowing()){
this.dropdown.removeClass("dropdown-open");
this.destroyScrollbar();
}
}
header_view.js:
app.views.Header = app.views.Base.extend({
templateName: "header",
className: "dark-header",
events: {
"focusin #q": "toggleSearchActive",
"focusout #q": "toggleSearchActive"
},
presenter: function() {
return _.extend({}, this.defaultPresenter(), {
podname: gon.appConfig.settings.podname
});
},
postRenderTemplate: function(){
new app.views.Notifications({ el: "#notification-dropdown" });
this.notificationDropdown = new app.views.NotificationDropdown({ el: "#notification-dropdown" });
new app.views.Search({ el: "#header-search-form" });
},
menuElement: function(){ return this.$("ul.dropdown"); },
toggleSearchActive: function(evt){
// jQuery produces two events for focus/blur (for bubbling)
// don't rely on which event arrives first, by allowing for both variants
var isActive = (_.indexOf(["focus","focusin"], evt.type) !== -1);
$(evt.target).toggleClass("active", isActive);
return false;
}
});
在回報率的應用程序,同時在圖標上點擊時,下拉打開和關閉的通知。 hideDropdown應該隱藏下拉打開時,但它沒有做,我得到的錯誤:
遺漏的類型錯誤:無法讀取的不確定
財產「厄爾尼諾」我相信它是與「本」 。誰能幫忙?
你可以在Chrome瀏覽器中的錯誤的堆棧跟蹤,然後讓我們知道哪一行到底是引發錯誤。更好的是,在該行上放置一個斷點並遍歷堆棧以查看元素未定義的原因。 –
這將是我第一次進行調試。在閱讀你寫的和一些研究成果後,我已經掌握了基礎知識。我不知道它是如何在rails應用程序中完成的,有些人使用調試器gem for rails。我想知道哪裏適合骨幹用途? – Mohammed
https://developer.chrome.com/devtools/docs/javascript-debugging&https://developer.chrome.com/extensions/tut_debugging - 這些應該會幫助你開始。 –