Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:35:06+00:00 2026-06-17T20:35:06+00:00

Problem: I’m trying to attach a resize event to the window from a view

  • 0

Problem:

I’m trying to attach a resize event to the window from a view using the new listenTo() method in Backbone.js. The event seems to bind to the window, however, when the window is actually resied the following error is thrown:

Uncaught TypeError: Object [object Object] has no method ‘apply’
jquery.js:2 p.event.dispatch
jquery.js:2 p.event.add.g.handle.h

Here is the code that attaches the event to the view:

this.listenTo($(window),"resize", this.resizeContext, this));

Here is the resizeContext function:

  resizeContext: function(event) {

            console.log("resizing context for "+this.id);

            this.setHeight();

            // trigger resize event (use event bus)
            this.options.vent.trigger("resize", event);

        }

Note: using the standard $(window).on("resize",this.resizeContext) attaches the event and runs as it should. I am trying to take advantage of the new stopListening() feature that is added to view.remove();

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:35:07+00:00Added an answer on June 17, 2026 at 8:35 pm

    The new listenTo and stopListening are methods of the Backbone.Events mixin, and they can only be used to listen to Backbone events which are triggered with .trigger, such as the built-in collection:add, or model:change events.

    That means that you won’t be able to utilize the stopListening functionality for DOM events such as window:resize.

    Consider overriding the View.removemethod instead.

    var SomeView = Backbone.View.extend({
      initialize:function() {
        $(window).on("resize",this.resizeContext)
      },
    
      remove: function() {
        $(window).off("resize",this.resizeContext);
        //call the superclass remove method
        Backbone.View.prototype.remove.apply(this, arguments);
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I am trying to build a recursive tree using a function and data
Problem: I'm streaming my video from a php file with stream_get_contents(); using Flowplayer as
Problem I have a Silverlight 5 application using the treeview from the SDK. Now
Problem I'm trying to log the data returned from a JSON call, and console.log(jsonData)
Problem: I'm trying to integrate a slider (carousel) inside an info window of google
Problem I'm trying to toggle between two functions when a button is clicked using
Problem Using Director 11.5 and Windows 7, with MouseWheel Xtra (wheelmouse.zip), I have the
Problem statement I'm trying to implement my own virtual keyboard following example softkeyboard, found
Problem: I'm attempting to disable a radio button by using the code below. This
Problem, simple and annoying. Im just trying to print a list of names, collected

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.