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 8313065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:22:23+00:00 2026-06-08T20:22:23+00:00

I get the basic idea about this not being in a method when in

  • 0

I get the basic idea about this not being in a method when in strict mode outlined here, but it gets a bit erudite, to be honest. So, in more prosaic terms:

I have a handler like so:

$('.myClass').one('keyup', function() {
    var $this = $(this);
    etc etc
});

I want to change it to this:

function myFunction () {
    var $this = $(this);
    etc etc
};
$('.myClass1').one('keyup', myFunction);
$('.myClass2').one('keyup', myFunction); etc

It doesn’t like it because in strict mode because I’m using this outside of a method. I get that.

However, I need to have myFunction separate to the handler, because (1) it’s attached to various classes/elements and (2) I am using .off().one('keyup', myFunction) to reset the one handler for various classes at various points.

So how do I get around having a separate callback function without violating the this business?

  • 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-08T20:22:25+00:00Added an answer on June 8, 2026 at 8:22 pm

    I get the basic idea about this not being in a method when in strict mode…

    Yes, but you’re confusing two unrelated things: Strict mode, and JSLint. They’re largely unrelated (except that JSLint has an option to require strict mode).

    There’s no problem with your code in strict mode. It’s perfectly valid and appropriate (because of how jQuery uses this). Example There is no “strict violation” there.

    JSLint doesn’t like it, but JSLint doesn’t like a lot of things that are perfectly valid and appropriate. JSLint detects a combination of things that are very widely-acknowledged to be problems (like missing semicolons), and things that Douglas Crockford doesn’t like from a style perspective. Crockford’s intelligent and well-informed, but not everyone agrees with his style choices.

    Lint tools are very helpful, an essential part of the toolkit. JSLint is less helpful than it might be (in my view), by conflating substance issues with style issues (although granted it’s a fine line, with JavaScript). You might consider using JSHint, a fork which gives you more control over what it checks.

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

Sidebar

Related Questions

I'm trying to get a basic sample across domains working, but I just cannot
I am attempting to get the basic form of crawler4j running as seen here
I'm experimenting with Spring Mobile but I can't seem to get the basic example
Using Wikiepdia API link to get some basic informations about some world known characters.
I know that it's not the main idea of this site to answer such
I'm using Python/Django, but this is more about the data model and how I
I've been trying to get this basic function to work for the last 2
I want to get some basic info of all contacts(I use api lvl 8).
I'm trying to get a basic flip animation transition working when I push a
I'm trying to get a basic datagrid for simple tabular input. The server will

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.