Simple example in Editor X. Have repeater in the page. Have 2 boxes inside repeater's item. #box1 - onClick
-expand() #box2 if collapsed,
-collapse() if !collapsed.
#box2 - collapsed by default. Works well on 1st dynamic page you visit or after you refresh (reload) the page. Doesn't work when you are being on the one dynamic page and go to the another one. What doesn't work: #box2 expanded by default instead of being collapsed.
I've trying to collapse it manually pageOnReady / datasetOnReady / repeaterOnItemReady. Whatever I’ve tried nothing worked...
The code is simple as that...
$w.onReady(function(){
$w("#boxN2").collapse();
});
export function repeater1_itemReady($item) {
$item("#boxN2").collapse();
}
export function boxN1_click(event) {
let $item = $w.at(event.context);
let box2 = $item("#boxN2");
box2.collapsed ? box2.expand() : box2.collapse();
}
The link on the published example is here:
https://vanyadoing.editorx.io/my-site-2/items/i-am-a-title-04
Try to go on others dynamic pages using the "Previous Item" / "Next Item" at the bottom of the page and you will see the problem. Thanks in advance for your time Cheers, Ivan
Perhaps you need to set the Fetch after the page loads option to ensure that the dataset is ready before the onItemReady() event handler is triggered.
I also see that the Previous Item and Next Item buttons aren't always responsive after going to the previous/next page. Not sure why that is.
Try the Fetch after the page loads option and let me know if that helps.
Hi @Ivan Alekseev 🖐
On the page you provided, I wasn't able to navigate to different items as the buttons are disabled, or at least doesn't work, however, tidying up your code might help as it's a mess right now;
$w.onReady(() => { $w('#repeater1').onItemReady(($item) => { $item("#boxN2").collapse(); $item("#boxN1").onClick(() => { if ($item("#boxN2").collapsed) { $item("#boxN2").expand(); } else { $item("#boxN2").collapse(); } }) }) })
You need to delete any static even handler you already have in order for this code to work.
Hope this helps~!
Ahmad
Can I also mention you @Yisrael (Wix) here to get a hope of an answer.
Hi @Ahmad ,
Do you think this could be fixed with the code?
I’ve also noticed the odd behavior. On some of the dynamic pages #box2 remains collapsed and on some the boxes got expanded... hmm