Are you actually using primary and secondary as the idâs of your sliders? If so, it wonât work. Youâll see the sliders still use the bricks assigned idâs regardless of what you set. I guess it might be considered a bug, although I canât say for sure.
Try running this from the console on the page with the sliders and youâll see what I mean.
I personally donât suggest to change the data attribute assigned by Bricks, unless we can confirm Bricksâs JS wouldnt use that, but pretty sure your screenshot error causing by that.
Check the instance Id like cmstew suggest.
And change like this
Alternatively, just use another way to retrieve the instance Id like this.
@cmstew I think the current way of remaining the bricksâ Id as instance Id is better, can imagine if people assigned same CSS Id for different sliders will cause more problem later
Iâve got to say though that both of you have gotten creative with the problem. I wouldnât have thought of changing the data attribute or using the id to get the data attribute. lol
I have now reinserted the original ID. Unfortunately, your code didnât work.
Now with the original ID, the sync works again, but I get an error again when I resize the window.
Uncaught ReferenceError: sliderSyncFunction is not defined
The same error in the console as in the screenshot above.
@cmstew I just tested it because I think itâs stupid to always look for the ID
This would also make it easy to copy without having to look for the ID againâŠ
yup! Its working perfectly now⊠Now Iâm learning JS with you guys haha
But Iâm still interested in the other way with the Extra ID⊠unfortunately that just didnât work.
The attribute is then called âdata-scriptIdâ right?
datasets translate to javascript a little confusingly if you donât know whatâs going on.
essentially if you have an html element with the id of primary and data-script-id=âprimaryâ as the attribute, you can access it with Javascript like this:
// data-script-id is translated to scriptId on the javascript side
var primary = document.getElementById('primary').dataset.scriptId
I really donât suggest to change any data attribute generated by Bricks
Because you donât know they might use it in some other places which suppose to check in other arrays or objects and required the original bricks Id.
Canât I just say I take the attribute itchycodeid for example?
So if I specify a custom attribute and then define it as primary and secondary and address it like this in the script?
Iâm sorry for the stupid question, but is that correct?
I have now changed the CSS IDs, deleted the attributes and left them on default. and adjust the script accordingly.
Yeah it works! I was confused because you guys started with âvarâ. I didnât know what to do with it!
Youâre right! I would like to learn Javascript for a long time. I hope I can find time for it soon!
Thank you very much! I wish you both a wonderful day.