jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree checkChange loops through sub items twice

Tagged: 

This topic contains 4 replies, has 3 voices, and was last updated by  desterly 12 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • mzavada
    Member

    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.


    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    checkChange loops through sub items twice #9697

    desterly
    Member

    Along 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.

    checkChange loops through sub items twice #9700

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    checkChange loops through sub items twice #9702

    desterly
    Member

    What 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
    ….D

    and 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.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.