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 2 events focus/blur (for bubbling) // don't rely on event arrives first, allowing both variants var isactive = (_.indexof(["focus","focusin"], evt.type) !== -1); $(evt.target).toggleclass("active", isactive); return false; } }); in ror app, when clicked on icon simultaneously, dropdown opens , closes notifications. hidedropdown should hide dropdown when opened doesn't , error:
uncaught typeerror: cannot read property 'el' of undefined
i presume has "this". can help?
had assigned el view? like:
headerview = new app.views.headerview el: '#header' you can specify selector el view http://backbonejs.org/#view-el
Comments
Post a Comment