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

  • Home
  • SEARCH
  • 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 8831401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:18:03+00:00 2026-06-14T08:18:03+00:00

I am having big trouble fixing this error. I have a view in Backbone.js

  • 0

I am having big trouble fixing this error.

I have a view in Backbone.js and I want to bind some actions on it with keyboard events.

Here is my view :

window.PicturesView = Backbone.View.extend({
    initialize : function() {
        $(document).on('keydown', this.keyboard, this);
    },
    remove : function() {
        $(document).off('keydown', this.keyboard, this);
    },
    render : function(eventName) {
        // blah blah blah
    },
    next : function() {
        // blah
    },
    prev : function() {
        // blah
    },
    keyboard : function(e) {
        console.log(e.keyCode);
        if (e.keyCode == 37) {
            this.prev();
            return false;
        }
        if (e.keyCode == 39) {
            this.next();
            return false;
        }
    }
});

When I press the keyboard, I get this error :
Uncaught TypeError: Object [object Object] has no method 'apply'
that is triggered by jQuery.

After reading this : Uncaught TypeError: Object [object Object] has no method 'apply'

I also tried :
$(document).on('keydown', function(e) {
this.keyboard(e);
}, this);

but it still gives me the same error.

And :
$(document).on('keydown', 'keyboard', this);
in the events : { 'event' : 'action' } style
but it doesn’t do anything.

I could probably find some hack by using jQuery only somewhere else in my code, but since I am not expert in event handling and Backbone, I want to run it the nice way.

I hope I’m clear, thanks

  • 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-14T08:18:04+00:00Added an answer on June 14, 2026 at 8:18 am

    @roatin-marth was right. The “on” function that was applying wasn’t the backbone one as I expected, which allows to pass the context as a parameter :
    $(document).on('keydown', this.keyboard, this);

    Since it’s a jQuery selector, it’s the jQuery on that applies. Hence I need a proxy to link with context:
    $(document).on('keydown',$.proxy(this.keyboard,this));

    All good, thanks for the help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having some trouble with matplotlib since I started using python. When
I'm having trouble aggregating multiple arrays into one big array, I think this should
I'm having some trouble with the syntax on this. SELECT a.[Id] ,a.[Ext] ,a.[Title] ,b.Text
I'm having trouble both tailing and scp-ing big files with msysgit (version 1.7.1.msysgit.0). This
There is a big design flaw here, but I'm having trouble solving it: The
In MVC app, I am having this big object that is used in classic
I'm having a very big struct in an existing program. This struct includes a
I have a big string having at most 100000 character. Instead of using string.charAt[index]
I'm having trouble passing a big array to a function in C. I declare:
I'm having big trouble in configuring Ruby and MySQL on MacOSX. Just a fact,

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.