jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree Raise an event on already clicked Tree Item

This topic contains 2 replies, has 3 voices, and was last updated by  castt 11 years, 4 months ago.

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

  • solveQueries
    Member


    Hi,

    I have a scenario where I have to raise an click event on already selected tree item. I already checked Tree API Documentation but there is an select event only which is not raising event on already clicked tree item.

    $(‘#jqxTree’).on(‘select’,function (event)
    {
    var args = event.args;
    var item = $(‘#jqxTree’).jqxTree(‘getItem’, args.element);
    var label = item.label;
    });


    Dimitar
    Participant

    Hello solveQueries,

    Here is how to bind to the click event:

    $("#jqxTree .jqx-tree-item").click(function () {
    alert("Clicked.");
    });

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    castt
    Participant

    Faced the same issue. Here is my solution.

    
            $('#tree').on('select', function (event) {
                var item = $('#tree').jqxTree('getItem', event.args.element);
                //do whatever with item
            });
    
            // helper to raise select event on already selected tree element
             $('#tree. jqx-tree-item').on('click', function () {
             	// Clear selection
             	$("#tree").jqxTree('selectItem', null);
             	var element_id = $(this).parent().attr('id');
             	// re-select element
             	$("#tree").jqxTree('selectItem', $("#tree #" + element_id)[0]);
             });
    
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.