Take the 2-minute tour ×

I'm trying to fire an event programmatically. My problem is that I have two SVG on two DIVs and I want to be able to change the border of the DIV I have clicked. To do that I thought to pass the DIV inside my classes and then trigger a click on it once I click on anything. (if there is a better way, please tell me)

I have the following code:

div = querySelector(divName);
svgElement = new svg.SvgSvgElement();

later I pass the svgElement to another class


where show is

show(svg.SvgElement element) {
  if (element.parent is DivElement){
    _parentDiv= element.parent as DivElement;

_parentDiv is of course a DivElement, which I use for an internal onClick()

_onClick(MouseEvent e) {
  window.console.info("onClick Ell");

I'm expecting to see the _setBorders(1); I defined with the main div, but it doesn't work. The weird thing is that when I check with the debugger set to the _parentDiv.click() I see that _parentDiv has the event correctly set. I suppose click() doesn't work as I expected. Any Idea?

share|improve this question
Don't you want div.onClick.listen((_) => _setBorders(1)); ? If not could you paste the _setBorders method ? –  Alexandre Ardhuin Feb 5 at 7:56
@Alexandre I might have done a copy mistake, but I thought that what I've written up here shouldn't have worked. What is the difference? –  mobinoob Feb 5 at 8:04
listen takes a Function in parameter. You don't paste the content of your _setBorders function but I expect from its name that the call of _setBorders(1) doesn't return a Function but rather void or null or nothing. If you want that _setBorders(1) is called on click events you have to use div.onClick.listen((_) => _setBorders(1)). –  Alexandre Ardhuin Feb 5 at 8:12
Why the wrong version doesn't give an exception? –  mobinoob Feb 5 at 8:46

1 Answer 1

up vote 3 down vote accepted


share|improve this answer
Thanks. I did indeed forgot the first part. I wonder why I didn't get an alert. –  mobinoob Feb 5 at 19:49

Your Answer


