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:
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
Hi @ahmadnasriya ,
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
Can I also mention you @yisrael-wix here to get a hope of an answer.
Hi @vanyadoing
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
Hi @ahmadnasriya
Thank you for your answer.
What I mean are these buttons.
They are enabled. At least if you are not on the last item and trying to go next. In this case try to use Previous Item button =)
About the code:
Have 2 different event handlers as was trying to have repeater connected to dataset and doesn’t.
While the expressions:
if ($item("#boxN2").collapsed {
$item("#boxN2").expand();
} else {
$item("#boxN2").collapse();
}
and
box2.collapsed ? box2.expand() : box2.collapse();
are probably the same things…
But whatever…
Even if I will erase all code from the page and will delete all event handlers as well it wont work…
I mean. Just look at this:
$w.onReady(function () {
$w("#boxN2").collapse();
})
Just the single code line. To collapse #boxN2 which is the box element inside the repeater’s item.
And here are the results I have:
going to this page https://vanyadoing.editorx.io/my-site-2/items/i-am-a-title-03
here is everything just fine.
#boxN2 hidden.
Then I move to the next dynamic page by clicking on “Previous item” button so what i see there are quietly weird…
All
#boxN2 boxes are expanded on page loads… While nothing should fired this… As the only code I have is to collapse them on ready.
The same thing happens if I use repeater on ready event handler and do collapse element with the $item.
that’s a problem…
Let me please know if something remains unclear from the description above.
@vanyadoing I checked the website again, and yet I can’t see my code there, yes, the conditional statement is the same, I just wanted it to be easier to understand for other members.
Try my code and let me know if that made any difference.
@ahmadnasriya no problem. Here we go:
Unfortunately, nothing happened…
I’ve deleted all static event handlers, and replace the code with yours…
Actually nothing would change even if I delete whole custom code from the page and will just leave checked option “collapsed” in “default values” for
#boxN2 in the properties panel.
You can see published results with your code here:
https://vanyadoing.editorx.io/my-site-2/items/i-am-a-title-02
@ahmadnasriya
Basically, all I want is just #boxN2 to be collapsed by default (onReady)
when the next dynamic page loads…
@vanyadoing there must be something we’re missing, I need to check the website and take a deeper look to find out what is going on.
@ahmadnasriya
Thank you if you find the time for this.
I’ve also contacted WIX support. I will let you know what they say.
Two more interesting things I’ve noticed.
1-) If to call console.log($item(”#boxN2”).collapse) inside the repeater onItemsReady it shows “true” even if the box actually expanded…
2-) When previewing the site in the editor’s preview mode. And switching the pages there is no such bug. Boxes are collapsed after the pages load.
Getting exiting and complicated.
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 @yisrael-wix
Thank you for your reply. I do really appreciate your time and help.
I’ve set the Fetch after the page loads option. But nothing have changed…
After I list the pages I get expanded boxes on some of the pages while on some of them they are collapsed …
The interesting fact about this is if you visit let’s say product page 1 (open the page first time or reload the page) you got boxes collapsed. What is fine. Than on next page product page 2 boxes would be expanded for some unknow reason. And if you continue moving on the product page 3 you would see the boxes collapsed again. And on the product page 4 they would be again expanded…
So logic is following:
Page N you visit ( collapsed ) => next one ( expanded ) => next one ( collapsed ) => next one ( expanded )…
Not sure why it happens. But I’ve trying to create a blank site with the only repeater like this one on dynamic pages and got the same behavior.
Seems like an common issue.
“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.”
=> haven’t created them. Used one of the WIX templates. Anyway I see that the buttons are just connected to dataset next/previous items using native way UI of editor. Anyway this is not a problem.
@vanyadoing I’m going to consult with QA on this.
I believe that this issue is related to a performance release that we had a while ago. I’ll discuss this with QA for a solution to the problem.
@yisrael-wix Thank you. Will be waiting for your reply. =)