Login Register

Dijit

programmatic widget creation

When programmatically creating a widget, class, style, and id now need to be specified as parameters to the constructor, not as attributes of the placeholder node. Example:

new dijit.form.Button({ "class": "large", style: "color: red" });

baseClass

The baseClass for a form widget must now be specified in the javascript instance, like:

templatePath: ...,
baseClass: "dijitTextBox",
...
rather than in the template.

attributeMap

Widget: a new attributeMap property has been added to widgets that automatically copies things like id and tabIndex into the widget's DOM tree. If you are writing custom widgets (or even just custom templates) you should be aware of it. When declaring markup on the page, standard attributes will now be mixed in with those in the Widget templates. However, when attaching to nodes programmatically using the widget constructor's second argument, carrying over attributes is no longer supported -- these attributes must be passed explicitly.

TextBox changes

Formatting for all the <input> widgets (TextBox, ValidationTextBox, ComboBox, etc.) has changed. You will need to update your CSS rules for customizing formatting.

  • width specification is now on outer node, like
    <input dojoType="dijit.form.TextBox" style="width: 10em;">
    or
    <style>  medium { width: 10em; } </style>
    	<input dojoType="dijit.form.TextBox" class="medium">
    Note that previously, you specified a pattern like .dijitComboBox INPUT { ... }. Remember that that if there's an error, that width will be split between the inpu area and the validation icon
  • specifying width via the size attribute is also desupported
    <input dojoType="dijit.form.NumberTextBox" size=4>
  • The maxlength attribute has been renamed to maxLength for greater browser compatibility.
  • The getTextValue() method has been renamed to getDisplayedValue() for both readability and for consistency of API with ComboBox.

ComboBox/FilteringSelect changes

The pageSize attribute was changed from a default of 30 to Infinity to better align with common customer use cases.

Tree

a number of changes to tree including specification of the root node and also that childAttr is now an array rather than just a scalar (this affects programmatic creation of trees).

Method name changes:

  • isFolder → isExpandable
  • makeFolder → makeExpandable

Widget lifecycle

create() (which calls postMixInProperties(), postCreate(), etc.) is now called from postscript(), which means that you should do widget initialization (stuff that needs to happen before the properties are mixed in) in constructor() rather than preamble(). I think preamble() will still work in most cases but constructor() is now the standard.

Typically people initialize arrays and objects in constructor() to avoid multiple widgets sharing the same object, although actually that generally isn't necessary. It's only really needed if you are writing directly into the object rather than setting it like this.foo = { ... }.

dijit.InlineEditBox

dijit.form.InlineEditBox was deprecated in favor of dijit.InlineEditBox, which has a new signature without a nested widget:

<span dojoType="dijit.InlineEditBox" editor="dijit.form.CurrencyTextBox" editorParams="{currency: 'USD'}" width="100px" autoSave="false"> $2,000 </span>

This new version still has some kinks to work out but is working in general, and should be faster since it doesn't instantiate the editor until it's needed. (In particular this is useful for using a heavy editor widget like dijit.Editor, although I haven't tried that yet.) Note that this implies that you have to write out the "display version" of the widget's value on the server, which could be complicated for things like currency due to internationalization issues. But I'm expecting the main use of InlineEditBox to be for editing plain or rich text, rather than numbers or currency.

dijit.popup

Most people don't use this class directly, but for those that do, note a few changes:

  • subMenu arg to open() is no longer necessary
  • closeAll() was removed; instead, close() now takes a pointer to the widget that it's closing, and it closes that widget plus anything that that widget popped up. In other words, it starts closing popups from the highest z-index popup and continues until it closes the specified popup.

Tooltip

If you for some rease were calling dijit.MasterTooltip.show() or dijit.MasterTooltip.hide() directly, now please call dijit.showTooltip(innerHTML, aroundNode) and dijit.hideTooltip(aroundNode) instead.

programmatic construction

I hear that this style of widget construction is no longer needed in 1.0.

var node = new dijit.Toolbar ({ 
                       id:'someId',
                       class:'someClass'
                       .......}, 
                      document.createElement('div'));

So what should we do with our custom widgets? Lets say I have a widget that inherits from dijt.Dialog. Right now if the second arg is not a domNode an error occurs: this.srcNodeRef.style.cssText is null or not an object. Here's the code:

dojo.declare ("ASIDijitDialogBuilder", dijit.Dialog, {
	     constructor: function (params, srcRefNode) {
     	    var parent = document.getElementById("container0");
     	  	console.log ("Combo button parent id is: " + parent.id);
	        alert ("Params are: " + params.id + "\n" + params.title); 
          var dialog = new ASIDijitDialogBuilder.superclass.constructor(
                        params, document.createElement("div"));

This requirement is there because the _Widget.js has this code:

dojo.declare("dijit._Widget", null, {
	constructor: function(params, srcNodeRef){
		this.create(params, srcNodeRef);
	},

However, the _Widget.js in 1.0 does not appear to have the same code. Instead it has create.

dojo.declare("dijit._Widget", null, {
    ...........
     create: function(params, srcNodeRef){
     }

So is the prescibed method to call create instead of constructor?

Thanks,

John

if statement

You need to use an if statement: if(this.srcNodeRef){ ... }

second question

Not sure what you mean. I guess my posting was confusing. Basically there were 2 questions:
1) Regardless of a conditional, the mere presence of a second arg in the constructor, causes the error code. It disappeared when I used the construction method that always creates a div and passes it in the second arg. However, if the second arg is not a domNode, the error appears. I have since worked around that. So it's less of an issue now. So, my second and only remaining question is:

2) In 1.0 do we create widgets with a constructor or with the create command?

Thanks,

John

test case

OK, you'll have to file a bug and attach a test case using the "attach file" button. We have tests that don't pass a second parameter and they work fine. Here's an example of an if statement from Menu.js:

if(this.srcNodeRef){
                        var nodes = dojo.query("*", this.srcNodeRef);
                        dijit.PopupMenuItem.superclass._fillContent.call(this, nodes[0]);

                        // save pointer to srcNode so we can grab the drop down widget after it's instantiated
                        this.dropDownContainer = this.srcNodeRef;
                }

Regarding:

2) In 1.0 do we create widgets with a constructor or with the create command?

There is no create command. The user creates widgets using the new() call, and that eventually causes the create() method to be called, but you shouldn't have to worry about any of that.

Dijit ToolTip

I had been using
dijit.MasterTooltip.show() and
dijit.MasterTooltip.hide() in Dojo 0.9 version. Could some one point out what is the corresponding port to 1.0 ( Also please update this page with that information )

Thanks,
Rakesh

thanks

Forgot to write that in the doc; I added it just now (see last entry in main post, above).

Attachpoints

Also, you forgot to mention that attach points can no longer be referenced in the widget constructor. Implement postCreate and access them in there.