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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:17:12+00:00 2026-05-26T01:17:12+00:00

I am trying to extend dijit.form.Button with an extra attribute but this is not

  • 0

I am trying to extend dijit.form.Button with an extra attribute but this is not working.Code is given below

In file1.js

dojo.require('dijit.form.Button');
dojo.extend(dijit.form.Button,{xyz: ''});

In file2.jsp

<script type="text/javascript" src="file1.js"></script>
<div dojoType="dijit.form.Button" xyz="abc"></div>

However when I look at the HTML of the created button (In chrome seen by right click and then selecting ‘inspect element’ option), it doesn’t show xyz attribute.

  • 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-26T01:17:13+00:00Added an answer on May 26, 2026 at 1:17 am

    You need to keep in mind that there’s a distinction between the widget object and its HTML representation. When you extend dijit.form.Button, the xyz attribute is added to the widget class, but not automatically to the HTML that the widget will render. So in your case, if you do

    console.debug(dijit.byId("yourWidgetId").get("xyz"));
    

    .. you’ll see that the button object does have the xyz member, but the HTML (like you point out) does not.

    If you also want it do be visible in the HTML, you have to manually add it to the HTML rendering of the button. One way to do that is to subclass dijit.form.Button and override the buildRendering method.

    dojo.declare("my.Button", dijit.form.Button, {
        xyz: '',
        buildRendering: function() {
            this.inherited(arguments);
            this.domNode.setAttribute("xyz", this.xyz); 
        }
    });
    

    If you add an instance of your new Button class in the HTML, like so:

    <div dojoType="my.Button" xyz="foobar" id="mybtn"></div>
    

    .. then the HTML representation (after Dojo has parsed it and made it into a nice looking widget) will contain the xyz attribute. Probably something like this:

    <span class="..." xyz="foobar" dir="ltr" widgetid="mybtn">
        <span class="..." dojoattachevent="ondijitclick:_onButtonClick">
        <input class="dijitOffScreen" type="button" dojoattachpoint="valueNode" ...>
    </span>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extend one of my WebApps using IronPython, unfortunately the code below
I'm trying to extend the DropDownList control to simply add one extra property. Code
I'm trying to extend an assoc array like this, but PHP doesn't like it.
I'm trying to extend (not sure what is the correct term for this kind
I'm trying to extend the TextBox , ComboBox and Panel controls using IExtenderProvider but
I'm trying to extend JButton with Clojure, but I ran into a problem when
I'm trying to extend a form and add an upload file field from within
I'm trying to extend the SPL ArrayObject but I've hit a little snag. Using
I'm trying to extend the functionality of an ASP.net application that I'm working with.
I'm trying to extend Object functionality this way: Object.prototype.get_type = function() { if(this.constructor) {

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.