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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:32:21+00:00 2026-06-18T12:32:21+00:00

The issue is i am following the tutorial here and the functionality of the

  • 0

The issue is i am following the tutorial here and the functionality of the new widget work fine until i hover over the widget where a this._changeBackground method is being called from “on” listeners, i get the error TypeError: this._changeBackground is not a function

The final code as implemented from tutorial looks like this:

define(["dojo/_base/declare","dijit/_WidgetBase", "dijit/_TemplatedMixin", "dojo/text!/JS/Allatus/Test.html", "dojo/dom-style", "dojo/_base/fx", "dojo/_base/lang","dojo/on"],
    function(declare, WidgetBase, TemplatedMixin, template, domStyle, baseFx, lang , on){
        return declare([WidgetBase, TemplatedMixin], {
            // Some default values for our author
            // These typically map to whatever you're handing into the constructor
            name: "No Name",
            // Using require.toUrl, we can get a path to our AuthorWidget's space
            // and we want to have a default avatar, just in case
            avatar: require.toUrl("JS/Allatus/custom/android_vector.jpg"),

           bio: "",

            // Our template - important!
            templateString: template,

            // A class to be applied to the root node in our template
            baseClass: "authorWidget",

            // A reference to our background animation
            mouseAnim: null,

            // Colors for our background animation
            baseBackgroundColor: "#fff",
            mouseBackgroundColor: "#def",
            postCreate: function(){
    // Get a DOM node reference for the root of our widget
    var domNode = this.domNode;

    // Run any parent postCreate processes - can be done at any point
    this.inherited(arguments);

    // Set our DOM node's background color to white -
    // smoothes out the mouseenter/leave event animations
    domStyle.set(domNode, "backgroundColor", this.baseBackgroundColor);
    // Set up our mouseenter/leave events - using dojo/on
    // means that our callback will execute with `this` set to our widget
    on(domNode, "mouseenter", function (e) {
        this._changeBackground(this.mouseBackgroundColor);
    });
    on(domNode, "mouseleave", function (e) {
        this._changeBackground(this.baseBackgroundColor);
    });
},
_changeBackground: function(toCol) {
    // If we have an animation, stop it
    if (this.mouseAnim) { this.mouseAnim.stop(); }

    // Set up the new animation
    this.mouseAnim = baseFx.animateProperty({
        node: this.domNode,
        properties: {
            backgroundColor: toCol
        },
        onEnd: lang.hitch(this, function() {
            // Clean up our mouseAnim property
            this.mouseAnim = null;
        })
    }).play();
},
_setAvatarAttr: function(av) {
    // We only want to set it if it's a non-empty string
    if (av != "") {
        // Save it on our widget instance - note that
        // we're using _set, to support anyone using
        // our widget's Watch functionality, to watch values change
        this._set("avatar", av);

        // Using our avatarNode attach point, set its src value
        this.avatarNode.src = av;
    }
}
        });
});

Any Ideas Why I cant call another function within my customize widget ? is that just a bug or i am doing something wrong?

  • 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-18T12:32:23+00:00Added an answer on June 18, 2026 at 12:32 pm

    Your mouseEnter function is being called outside the scope of your widget (scope in JS refers to the value of the “this” variable). This is a common problem and dojo has a simple solution, the function lang.hitch can be used to tie a function to a certain scope. (and more, I would recommending reading the docs on it). Here’s how you should use it in this scenario :

    // Set up our mouseenter/leave events - using dojo/on
    // means that our callback will execute with `this` set to our widget
    on(domNode, "mouseenter", lang.hitch(this, function (e) {
        this._changeBackground(this.mouseBackgroundColor);
    }));
    on(domNode, "mouseleave", lang.hitch(this, function (e) {
        this._changeBackground(this.baseBackgroundColor);
    }));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My brain is scrambled with this issue. I've been following a tutorial on Seeding
I am currently following this tutorial . Until now, I have met so many
I am following this tutorial . All is going well until I try create
I am new to WP7 programming and I have been following this tutorial http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx
Have been following this fabulous tutorial . Being new to Javascript and functional programming,
I've been following this tutorial . When i started the new app in chapter
Currently GDB has an issue following child processes after a fork. A work around
I faced following issue with my work: having two projects: MFC .dll and MFC
I have the following issue related to iterating over an associative array of strings
Following some well-known OpenGL Haskell tutorial , I've made my first HOpenGL program. Here's

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.