hello everyone,
I am working on a BRIC with which a map with OSM or other layers can be used.
If the BRIC is used several times: how do I get it to use a different ID each time? In the Bric Builder you can specify an ID in the HTML. If the BRIC is used a second or third time on the same page, I want a different ID each time.
The initialization and communication of the card starts with this ID.
In your custom-bric.js you could either generate an ID (math random) in the init function.
I guess you have an own JS library then calling the leaflet.js library for initialization? There you could also generate IDs inside the DOM before initialization of leaflet.js.
ok, thanks for the direction, then i’ll have to keep looking. shimmying around in the dom tree would be a last option.
Manually entering an ID would also be ok.
i understood that i can use custom-bric-id-target to instruct which element is assigned an id that is entered in the id field. if not, what does custom-bric-id-target do?
My experiments have not helped…
I have solved the ID problem thanks to your help and I am one step ahead
But the next question arises. I would like to validate the entries in the Bric interface. Specifically, only “0…9” and “.” should be allowed in the “Latitude” field. In some countries the “,” is used.
In the file “custom.js” I catch this and would like to write it back into the interface field. I also have fields whose value affects other fields.
Is there a way back into the interface fields or does it only work in the other direction.
Yes, I do this in some of my brics, formatting class names using a function in custom.js. Replacing spaces with hyphens and making sure it starts with a “.” It works well. I have other fields that will only accept numbers and rejects special characters and letters.
And I update the field with a UI call. (everything you can do, is in the dev docs.)