Login Register

passing parameter to "declarative" custom widget. [solved]

Update: wildbill helped me in #irc and solved the problem: You have to add a "defaults" attribute to the declaration tag. The attribute value must be a JSON hash that lists the members of the widget and their initial values. So the correct declaration is:

<div
        dojoType="dijit.Declaration"
        widgetClass="dijit.ecs.forms.forderung.xanlegen"
        defaults="{ foo: 'bar' }
>

==========================================================================

mornin'

I have this problem. I have a custom widget which consists of several form elements and basically looks like so:

<div
        dojoType="dijit.Declaration"
        widgetClass="dijit.ecs.forms.forderung.xanlegen"
       
>
        <form
                action="${foo}"
                id="${id}_forderung_anlegen_div"
        >
....

The calling code looks like this:

<div
                dojoType="dijit.ecs.forms.forderung.anlegen"
                id="[% form_uid %]"
                foo="bar"
        >
        </div>

However, this doesn't work. Firebug says:

Error("dijit.ecs.forms.forderung.xanlegen template:foo")@:0\n(undefined,"foo")@http://localhost:3000/...

and when I remove the

action="${foo}"

it works. Why, what am I missing? And how can I "declare" a parameter?

I've also played around with putting the same html into a "template" (like in the FileUpload example). That kinda worked too, but then widgets looked like ordinary html input elements, the dojo magic didn't work. Any clues on that?

Ty

I have the same issue using Declaration parameters in Javascript

I have a dijit.Declaration with parameters set up in the "default" attribute of the declaration DIV. If I want to include a script that describes an onmouseover event which should fire off an alert box that references one of the parameters, how would I go about doing that? Using the curly braces in Javascript denotes a block of code so the browser cries foul.

Example:

<div dojoType="dijit.Declaration" widgetClass="myTestClass" defaults="{ myName: 'John Doe' }">
Hey, ${myName}, click this button right here --&gt; <button dojoAttachEvent="onmouseover" dojoAttachPoint="containerNode"></button>
<script type="dojo/connect" event="onmouseover">
var myName = ${myName};
alert("Hey, " + myName + ", GIVE ME MY SPACE!!!");
</script>
</div>