Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#4999 closed defect (invalid)

How to get args from a dialog programmatically?

Reported by: guest Owned by:
Priority: high Milestone:
Component: Dijit Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description

The tests indicate that a Dialog function excecute() is invoked with args that the user has input. This works as specified when embedded in HTML. However, as usual, there are little or no examples of how to do this programmatically.

So - left to our own devices, I came up with the following, which does not work as hoped for.


var foobar = function foo(arguments) {

alert ("A dialog event fired." + arguments);

}

var dialog = new dijit.Dialog({

id:"dialog1", title:"Dialog1", execute:foobar (arguments)}, document.createElement("div"));

This, of course causes the function foobar to be invoked at construction time. So I changed the execute property to: var dialog = new dijit.Dialog({ id:"dialog1", title:"Dialog1", execute:foobar},

document.createElement("div"));

Now foobar is invoked, as expected. However, it does not have any arguments. In fact I am not sure what Object it is receiving. The alert show object Object. And attempts to dereference the object result in undefined.

Of course there is neither the documentation nor tests to show the user community how to do this. Every time I take one step forward with this toolkit, I take 10 steps back. It's ridiculous.

Change History (9)

comment:1 Changed 12 years ago by bill

Resolution: invalid
Status: newclosed

foobar is invoked with an object containing name/value pairs for the fields in the dialog. See test_Dialog.html for an example, which prints said values in an alert.

comment:2 in reply to:  1 ; Changed 12 years ago by guest

Resolution: invalid
Status: closedreopened

Replying to bill:

foobar is invoked with an object containing name/value pairs for the fields in the dialog. See test_Dialog.html for an example, which prints said values in an alert.

Yes I know that. I've tried these tests programmatically and they work. This does not work. Please try these examples out. I have spent many long hours trying these tests out first in embedded HTML and then programmatically. I probably have close to 100 tests on each combination of widgets and how they behave. So, please try out my examples. Thanks.

comment:3 in reply to:  2 Changed 12 years ago by guest

Replying to guest:

Replying to bill:

foobar is invoked with an object containing name/value pairs for the fields in the dialog. See test_Dialog.html for an example, which prints said values in an alert.

Yes I know that. I've tried these tests in embedded HTML and they work. This does not work. Please try these examples out. I have spent many long hours trying these tests out first in embedded HTML and then programmatically. I probably have close to 100 tests on each combination of widgets and how they behave. So, please try out my examples. Thanks.

comment:4 Changed 12 years ago by bill

OK, you'll need to attach a test case using the "attach file" button.

comment:5 in reply to:  4 Changed 12 years ago by guest

Replying to bill:

OK, you'll need to attach a test case using the "attach file" button.

So here's what I found. The test case has the following code:

div dojoType="dijit.Dialog" id="dialog1" title="First Dialog"
                execute="alert('submitted w/args:
' + dojo.toJson(arguments[0], true));">

And what I had to do was this:

var foobar = function foo(arguments) {
    alert ("A dialog event fired." + arguments);
    alert ("Name is: " + arguments.name);
    alert ("Location is: " + arguments.location);
    alert ("Owner is: " + arguments.owner);
    alert ("Arguments are: 
 : " + dojo.toJson(arguments, true));
}

comment:6 Changed 12 years ago by bill

Resolution: invalid
Status: reopenedclosed

OK, glad you got that working.

comment:7 in reply to:  6 Changed 12 years ago by guest

Replying to bill:

OK, glad you got that working.

Thanks. So, I took your working code from #4998 and used it on the dialog and behold - it worked as it does in the tests. Many thanks for your help. Here is the code fragment.

 dialog = new dijit.Dialog({
             id:"dialog1",
             title:"Dialog1",
             execute: function(){foobar(arguments);}},
             document.createElement("div"));

then the rest of the construction code for tables, buttons.....etc

var foobar = function foo(arguments) {
    alert ("A dialog event fired." + arguments);
    alert ("Name is: " + arguments[0].name);
    alert ("Location is: " + arguments[0].location);
    alert ("Owner is: " + arguments[0].owner);
    alert ("Arguments are: 
 : " + dojo.toJson(arguments[0], true));
}

comment:8 Changed 12 years ago by bill

Great. And BTW you no longer need the dummy node second argument on new Widget({}, document.createElement("div")) (for any widget). But that's a recent change, so you need the latest code before you can omit that arg.

comment:9 in reply to:  8 Changed 12 years ago by guest

Replying to bill:

Great. And BTW you no longer need the dummy node second argument on new Widget({}, document.createElement("div")) (for any widget). But that's a recent change, so you need the latest code before you can omit that arg.

Sounds good - thanks again.

Note: See TracTickets for help on using tickets.