jQWidgets Forums
jQuery UI Widgets › Forums › Navigation › Tree › checkChange loops through sub items twice
Tagged: checkChange
This topic contains 4 replies, has 3 voices, and was last updated by desterly 12 years, 7 months ago.
-
Author
-
I have notice that after placing a check in the parent item, the checkChange event handler seems to loop through the child elements twice causing the function in the event handler to fire a second time for each child element. This is causing my function, which toggles an item on and off a map, to get called twiced and hence placing and then quickly removing the item. Clicking on a child checkbox individually the function is only called once and hence the toggle function is only called once.
Is there a way to prevent the checkChange event handler from firing twice on all child checkboxes? Thank you.
Hi mzavada,
It depends on whether you have 3-state checkboxes or not. If you have 3-state checkboxes where checking a sub item, updates the check state of a parent item, or checking a parent item will update the check state for all sub items, the event will be fired multiple times – for a child item, for a parent item and so on.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comAlong the lines with this.
Is it possible to identify the actual item that is clicked in the event -vs- the parent/child options that are being clicked?
In my event I’m attempting to update a database that stores what items are actually checked but want the display to be in the threestates.
The issue is w/ the event is fired for the parent elements, event.args.checked is returning true for them all instead of an ‘intermediate’ for the parent items resulting in additional items being flagged in my database.
Hi desterly,
The event is triggered for the clicked item and after that for its parent items.
To get the element, use:
var element = event.args.element;
Having the element, you can get the item by using the jqxTree’s getItem method and passing the element as parameter.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comWhat I am attempting to do is isolate the actual clicked item on the loop due to the fact that it’s triggered for the parent items.
For example if i have:
A
..B
..C
….Dand the user clicks on “C”, the event is fired for C,D,A,C,D.
In my checkChange event I only want to update the database for the “C” element and not for the other items that are called. Currently I don’t see a way to isolate from the passed event only the clicked (C) element.
-
AuthorPosts
You must be logged in to reply to this topic.