Login Register

[solved] Including an existing dijit in a custom widget?

Hello, everybody:

I'm working on a custom widget.

I would like to have the widget include a dijit.form.ValidationTextBox.

I've got an input field in my widget template's html, with the required attributes for creating a ValidationTextBox.

I've tried dojo.require(dijit.form.ValidationTextBox) in the page that uses the custom widget

I've also tried including dijit.form.ValidationTextBox as a superclass in the widget's dojo.declare. But, I don't really want to extend ValidationTextBox, I just want an instance of it.

In all the cases above, the resulting page renders an input field, but it's not the ValidationTextBox widget, just a POHO (Plain Old HTML Object).

I would appreciate any suggestions or examples.

Thanks!
Greg

Make sure in your custom

Make sure in your custom widget that you set the property widgetsInTemplate to be true...for example:

In your custom widget.js:

dojo.require("dijit.form.ValidationTextBox");

dojo.declare("my.custom.widget", [dijit._Widget, dijit._Templated], {
  templatePath: dojo.moduleUrl("my.custom", "templates/widget.html");
  widgetsInTemplate: true,
  /*  Other custom functions */
});

and in your template widget.html:

<div><input dojoType="dijit.form.ValidationTextBox"></div>

Hope that helps...

-Nathan

That did, thanks!

Nathan:

Brilliant!

Thanks,
Greg