This is a migrated thread and some comments may be shown as answers.

Link Collapsible Widgets together?

2 Answers 50 Views
Collapsible
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 08 Apr 2015, 09:35 PM

Is it possible to link multiple collapsible div containers together in operation so that only one can be open at a time?

Right now this is how I have it operating. It works, but I'm not sure if this is the best way to accomplish such a thing.

 

onCollapsibleExpand: function(e){
        var thisID = $(this.element).attr("id");
        $(".km-collapsible").each(function(k,v){ 
            // if not clicked item and is currently visible 
            if( ($(this).attr("id") != thisID) && $(this).is(":visible") ){
                $(this).data("kendoMobileCollapsible").collapse();
            }
        });
    },

2 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 10 Apr 2015, 08:31 AM

Hello David,

There is no out of the box support for this, but you can simplify the logic, instead of:

    $(".km-collapsible").each(function(k,v){ 
        // if not clicked item and is currently visible 
        if( ($(this).attr("id") != thisID) && $(this).is(":visible") ){
            $(this).data("kendoMobileCollapsible").collapse();
        }
    });

You can apply the filter in the selector, and call the method directly:

         $(".km-collapsible:visible:not(#" + thisID + ")").kendoMobileCollapsible("collapse");

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
David
Top achievements
Rank 2
answered on 10 Apr 2015, 01:16 PM

ooh. That's nice. I wasn't aware about the ":not" filter.

Thanks for the tip! 

Tags
Collapsible
Asked by
David
Top achievements
Rank 2
Answers by
Alex Gyoshev
Telerik team
David
Top achievements
Rank 2
Share this question
or