0 points

How to expand and collapse elements inside repeaters in Wix


dashboard

Thu Jan 02 2020 19:00:00 GMT+0000 (UTC)

Posted by @mishka #wix #howto

$w.onReady(function () {
	$w('#collapsedelement').collapse();
    $w('#closebtn').hide();
});

export function openbtn_click(event) {
	let $item = $w.at(event.context);

	if ($item("#collapsedelement").collapsed) {
		$item("#collapsedelement").expand();
		$item('#openbtn').hide();
		$item('#closebtn').show();

	} else {
		$item("#collapsedelement").collapse();
		$item('#openbtn').show();
		$item('#closebtn').hide();
	}
}

export function closebtn_click(event) {
	let $item = $w.at(event.context);

	if ($item("#collapsedelement").collapsed) {
		$item("#collapsedelement").expand();
		$item('#openbtn').hide();
		$item('#closebtn').show();

	} else {
		$item("#collapsedelement").collapse();
		$item('#openbtn').show();
		$item('#closebtn').hide();
	}
}
content_copy

Where: #collapsedelement is the collapsed element. #openbtn is the element that reveals the collapsed element when clicked. #closebtn is the element that hides the collapsed element when clicked.



>> Browse more code snippets

more_vert