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…
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.