Opened 3 years ago

Closed 3 years ago

#18789 closed defect (invalid)

dojo's event.preventDefault() not working on dojo 1.8 version

Reported by: arunk89 Owned by:
Priority: undecided Milestone: tbd
Component: Dijit Version: 1.8.10
Keywords: Cc:
Blocked By: Blocking:

Description

I am upgrading the DOJO from 1.4 to 1.8 version. Now, I defined the dojo acccordian widget.I need to stop expanding Accordian widget at the onclick event.

when we used the dojo version 1.4 it worked and , We used the following snippet to stop the onclick event.

Template like below :

<div data-dojo-type="dijit.layout.AccordionContainer?" style="height: 300px;" onclick="onClickHandler">

Js like Below:

function onClickHandler(evt){

dojo.stopEvent(evt);

}

Got stucked on the following problem on 1.8 Dojo version :

As per the dojo official website https://dojotoolkit.org/reference-guide/1.8/dojo/stopEvent.html# , they are reporting the dojo.stopEvent() deplrecated.we need to use evt.preventDefault() and evt.stopPropagation() instead.

When I tried the onclickhandler like below , its not stopping the onclick event.

function onClickHandler(evt){

dojo.stopEvent(evt); evt.preventDefault(); Instead of the stopEvent evt.stopPropagation();

}

I cannot figure out the problem. Both Chrome and Firefox don't fire any error or exception, so as per my knowledge, no syntax errors.

I tried to 'return false' instead of above mentioned preventDefault & stopPropagation as well.even though its not stopping the onclick event of accordian pane.

Please help me to resolve it.

Thanks in advance

Change History (1)

comment:1 Changed 3 years ago by bill

Component: GeneralDijit
Resolution: invalid
Status: newclosed

There's a dijit.layout._AccordionButton sub-widget that has an _onTitleClick() method which is getting called before your onclick() handler even runs.

So, setting onclick() won't work. You could override _onTitleClick() or alternately the Accordion's selectChild() method.

Note: See TracTickets for help on using tickets.