Select to view content in your preferred language

dijit.ColorPalette

990
2
Jump to solution
09-28-2012 02:33 PM
BanchanaPandey
Regular Contributor
Hi,
I am trying to use a dijit.ColorPalette and I noticed that there is no more the onchange function that used to be there.
I am using javascript version 3.1.
How do you return the color selected from the dijit.ColorPalette object when there is no onchange method for it.
Thanks!
0 Kudos
1 Solution

Accepted Solutions
__Rich_
Deactivated User
This one connects to the onChange event of the widget instance:
Okay, I noticed that if I did like this below, it works and the onChange event fires.
var myPalette = new dijit.ColorPalette({
                palette: "7x10",
                onChange: function (val) { alert(val); }
            }, "divColorPalette");

<div id="divColorPalette"></div>


This one connects to the onChange event of the div element:

But if i do like this, it won't work. I have tried changing onChange to onchange and still it doesn't fire if I declare like this below.
dojo.connect(divColorPalette, "onChange", function (val) {
            alert(val);
        });

<div id="divColorPalette"  data-dojo-type="dijit.ColorPalette"></div>

In this case the onChange event:
a) doesn't exist
b) even if it did exist (!) isn't the same event

If you want to do it the second way i.e. using dojo.connect then you need to connect to the widget instance, not the DOM element.

Does that make sense?

(this might help - Writing Widgets#creating-extension-points)

View solution in original post

0 Kudos
2 Replies
BanchanaPandey
Regular Contributor
Okay, I noticed that if I did like this below, it works and the onChange event fires.
var myPalette = new dijit.ColorPalette({
                palette: "7x10",
                onChange: function (val) { alert(val); }
            }, "divColorPalette");

<div id="divColorPalette"></div>

But if i do like this, it won't work. I have tried changing onChange to onchange and still it doesn't fire if I declare like this below.
dojo.connect(divColorPalette, "onChange", function (val) {
            alert(val);
        });

<div id="divColorPalette"  data-dojo-type="dijit.ColorPalette"></div>

Why it would work the first way and not the second?




so I just create a div tag and do not declare the div as dojo-data-type="dijit.ColorPalette"
0 Kudos
__Rich_
Deactivated User
This one connects to the onChange event of the widget instance:
Okay, I noticed that if I did like this below, it works and the onChange event fires.
var myPalette = new dijit.ColorPalette({
                palette: "7x10",
                onChange: function (val) { alert(val); }
            }, "divColorPalette");

<div id="divColorPalette"></div>


This one connects to the onChange event of the div element:

But if i do like this, it won't work. I have tried changing onChange to onchange and still it doesn't fire if I declare like this below.
dojo.connect(divColorPalette, "onChange", function (val) {
            alert(val);
        });

<div id="divColorPalette"  data-dojo-type="dijit.ColorPalette"></div>

In this case the onChange event:
a) doesn't exist
b) even if it did exist (!) isn't the same event

If you want to do it the second way i.e. using dojo.connect then you need to connect to the widget instance, not the DOM element.

Does that make sense?

(this might help - Writing Widgets#creating-extension-points)
0 Kudos