Only allow one drawer open at a time

I'm using a enyo.DataRepeater to create enyo.Drawer's but am finding difficulty in allowing only one to be open at a time.
I've noticed moon.Accordion has this functionality when used inside a kind: "Group" but I can't seem to use the moon.Accordion inside my enyo.DataRepeater successfully.

Can anyone provide some insight as to how I may accomplish this?

Comments

  • edited August 2014
    I think the simplest way would be to bind the selected property for each DataRepeater item to the open property of the drawer.

    http://jsfiddle.net/oxf2gLgt/
    enyo.kind({
    	name: "ex.App",
    	components: [
    		{name: "list", kind: "enyo.DataRepeater", components: [
    			{kind: "onyx.Item", components: [
    				{name: "label"},
    				{name: "drawer", kind: "onyx.Drawer", open: false, components: [
    					{content: "Socks"},
    					{content: "Shirts"}
    				]}
    			], bindings: [
    				{from: ".model.label", to: ".$.label.content"},
    				{from: ".selected", to: ".$.drawer.open"}
    			]}
    		]}
    	],
    
    	create: enyo.inherit(function (sup) {
    		return function () {
    			sup.apply(this, arguments);
    			this.$.list.set("collection", new enyo.Collection([
    				{label: "Top"},
    				{label: "Middle"},
    				{label: "Bottom"},
    			]));
    		};
    	})
    });
  • Brilliant!
    That works like a charm!
    Thank you so much!
Sign In or Register to comment.