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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:59:14+00:00 2026-06-10T16:59:14+00:00

I had a hard time trying to find out why my assignments where lost,

  • 0

I had a hard time trying to find out why my assignments where lost, and found that callbacks scope was different than I thought.

What I did was to create a variable in a controller, then trying to pass a callback to a window created by the controller, then, on an event on that window, call-back a function in the controller.

For example, in my controller I have:

callWindow: function(){
  var myWin = Ext.Create('MyApp.view.myWin', {doSomething: this.doSomething});
},

doSomething: function(data){
  this.myData = data;
},

useTheData: function(){
  console.log(this.myData);
}

In myWin’s controller, I have an even handler that calls doSomething this way:

onBtnClick: function(button){
  var win = button.up('window');
  var data = {id: 1, name: "John"}; // please, don't pay attention to this, it's a record I'm passing to the caller.
  win.doSomething(data);
}

As you can see, in “doSomething” function, I’m assigning the controller var myData, with the value passed by the window’s controller. Initially I thought the scope of “doSomething” was the caller controller, but it’s the window’s controller, that’s why useTheData gives an error saying this.myData is null.

I’ve solved the problem by passing a new parameter named “caller: this”, and in doSomething, receiving that parameter, and using it instead of “this”.

The question is, is there a easy (with less steps) way to do this?.

  • 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-10T16:59:16+00:00Added an answer on June 10, 2026 at 4:59 pm

    You need to apply a scope for your callback to the window and use Ext.callback

    callWindow: function(){
      var myWin = Ext.Create('MyApp.view.myWin', {doSomething: this.doSomething, scope: this});
    },
    
    onBtnClick: function(button){
      var win = button.up('window');
      var data = {id: 1, name: "John"}; // please, don't pay attention to this, it's a record I'm passing to the caller.
      Ext.callback(win.doSomething, win.scope, [data]);
    }
    

    This is one way, your solution is another and there are even more.

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

Sidebar

Related Questions

I've had a hard time trying to find good examples of how to manage
I'm using the jQuery plugin for TinyMCE and have had a hard time trying
I've had a hard time sitting in front of UML and getting value out
I've had a hard time finding anything like what I'm trying to accomplish, seems
I had hard time to figure out why I've been getting unknown action error
I had a hard time trying to word my question properly, so i'm sorry
I am having a hard time trying to figure out which data type I
Please forgive the bad title - I had a hard time trying to think
I have a malformed page to scrape, and have had a hard time getting
I'm new to C# coming from a python background. I've had a hard time

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.