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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:14:52+00:00 2026-05-14T19:14:52+00:00

this Application.EventManager.on(‘Click’, function(args) { // event listener, args is JSON TestAction.getContents(args.node.id, function(result, e) {

  • 0
this
Application.EventManager.on('Click', function(args) { // event listener, args is JSON
    TestAction.getContents(args.node.id, function(result, e) { 
        console.log(result);
        this.add({
            title: args.node.id,
            html: result
        }).show();
    });
});

I’m really struggling with scope and anonymous functions… I want this (on the 1st line) to be the same object as this (on the 5th line)… .call() and .apply() seemed to be the right sort of idea but I don’t want to trigger the event… just change it’s scope….

For a bit of contexts… the this in question is a TabContainer and TestAction is a RPC that returns content…

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-05-14T19:14:53+00:00Added an answer on May 14, 2026 at 7:14 pm

    What you need is a variable defined on the outside scope that is set to this:

    var that = this;
    Application.EventManager.on('Click', function(args) { // event listener, args is JSON
        TestAction.getContents(args.node.id, function(result, e) { 
            console.log(result);
            that.add({
                title: args.node.id,
                html: result
            }).show();
        });
    });
    

    Thanks to closures, you can do this (err, that), even inside of a function.

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

Sidebar

Related Questions

I have this application that directs users to Types of attractions with this function:
this application requires: first click will change image1 to image2 second click will change
This application is using windows integrated authentication in IIS. No anonymous login. It's also
My application structure is like this: application modules default student controllers forms studentParent.php models
I have this application where I implement the ActionBar Fragment interface. Underlying the interface,
Please note this application will never be running on a server system. I am
I'm building this application using PHP, MySQL and jQuery. Essentially it's a checklist management
I have this application written in JSF 2.0 facelets and it has the following
I'm working on this application that's sort of like a blog. I'm thinking about
i have this application but how to use its? and example for 7-zip can?

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.