dojo.connect event object not working in IE7

1150
5
04-18-2012 06:31 AM
BrianGoad
Emerging Contributor
We have an application required to run on IE7 and we've encountered a problem with an event object passed into a function during a dojo.connect "onclick". evt.graphic.symbol.type is coming in as "not defined" in IE7, but works in Firefox. The code:

dojo.connect(this.map,"onClick", function(evt) {

if(evt.graphic.symbol.type == "textsymbol")
{
   // do something
}
else
{
   // do something else
}
});

Should this work in IE7?
0 Kudos
5 Replies
JeffPace
MVP Alum
We have an application required to run on IE7 and we've encountered a problem with an event object passed into a function during a dojo.connect "onclick". evt.graphic.symbol.type is coming in as "not defined" in IE7, but works in Firefox. The code:

dojo.connect(this.map,"onClick", function(evt) {

if(evt.graphic.symbol.type == "textsymbol")
{
   // do something
}
else
{
   // do something else
}
});

Should this work in IE7?



My guess is this is due to the fact that IE uses canvas and everything else uses SVG.

if you alert evt.graphic.symbol i bet you get different results in IE and others.  YOu will have to do a dojo.isIE<9 and trap for canvas element or check dojox.gfx.renderer==="vml" and then do your event.
0 Kudos
derekswingley1
Deactivated User
My guess is this is due to the fact that IE uses canvas and everything else uses SVG.

if you alert evt.graphic.symbol i bet you get different results in IE and others.  YOu will have to do a dojo.isIE<9 and trap for canvas element or check dojox.gfx.renderer==="vml" and then do your event.


IE 7 uses VML, which is different from canvas, wanted to point that out.

You should be checking for properties on objects before accessing them. Try something like:
if( evt.graphic.hasOwnProperty("symbol") &&
    evt.graphic.symbol.hasOwnProperty("type") &&
    evt.graphic.symbol.type == "textsymbol") {
// do something
} else {
// do something else
} 
0 Kudos
JeffPace
MVP Alum
derek is absolutely right, VML for IE7 (and 8 i believe).
0 Kudos
BrianGoad
Emerging Contributor
Ah, so IE7 is probably blowing up because it passes a different type of object there (VML vs Canvas). Did not expect it would be different.

Your help is very much appreciated.
0 Kudos
derekswingley1
Deactivated User
Ah, so IE7 is probably blowing up because it passes a different type of object there (VML vs Canvas). Did not expect it would be different.

Your help is very much appreciated.


Technically, dojox's gfx should abstracting the differences away for you. Test it out and let us know what you find.
0 Kudos