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

The Archive Base Latest Questions

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

I am having trouble figuring out how to use dojo/aspect with widgets. Consider the

  • 0

I am having trouble figuring out how to use dojo/aspect with widgets.

Consider the following:

require( [ 'dijit/form/Button' ],
function( Button)
{
    var myButton = new Button({label: 'Click me!'});
} );

How would I connect to the button’s postCreate() or startup() methods to discover when it has been rendered?

There seems to be no point when I can add advice to a method. See the comments, here:

require( [ 'dijit/form/Button', 'dojo/aspect' ],
function( Button, aspect )
{
    // I cannot use aspect.after() here as I have no instance yet
    var myButton = new Button({label: 'Click me!'});
    // ...but I cannot do it here either as the lifecycle has already kicked off
} );

(The button is just to make it easier to explain the issue. My real-world problem involves widgets that contain other widgets, so I need to know when the whole lot have rendered before performing an action).

  • 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-14T16:13:22+00:00Added an answer on June 14, 2026 at 4:13 pm

    By instantiating the widget programmatically, the postCreate method of the widget is implicitly being called. As far as I know there isn’t an easy (or really a good reason to) to connect to the postCreate stage in the widget lifecycle.

    startup, on the other hand you need to call explicitly when programmatically instantiating a widget:

    var myButton = new Button({label: 'Click me!'});
    aspect.after(myButton, 'startup', function(){
        console.log('startup called');
    });
    //place button in page (since startup implies the widget has been placed in the page
    myButton.placeAt(someDomNode)
    myButton.startup();
    

    If you want to do work during the postCreate lifecycle of a widget, you’ll likely want to subclass that widget. Doing so would look something like this:

    //in a file like my/custom/widget.js
    define(['dojo/_base/declare','dijit/form/Button'],function(declare,Button){
      return declare('my.custom.widget',[Button],{
        postCreate:function(){
          //we still want to call the parent class's postCreate function
          this.inherited(arguments);
          //create some other widgets as well
        }
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a bit of trouble figuring out the exact syntax to use
I'm having trouble figuring out how to filter a queryset appropriately for the following
I'm having trouble figuring out how to use soundfonts on android (that have a
I am having trouble figuring out how to use .Include() to be able to
I'm having trouble figuring out how could I use my imagebutton (see below) in
I'm having some trouble figuring out how to use more than one left outer
I am having trouble figuring out how to use a sting as an object
I am having trouble figuring out how to use sed to search and replace
I'm having trouble figuring out how to use LAST_INSERT_ID() for a MySQL database in
I'm having trouble figuring out whether or not I can do the following: I

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.