Is it possible to use dynamic text inside Custom Attributes?
I tried this but it doesn’t work:
Is it possible to use dynamic text inside Custom Attributes?
I tried this but it doesn’t work:
Unfortunately it’s not possible, but you can always use JS. @Finsweet was awesome enough to put together a helper script for their Filter functionality that takes the text within a specific element and injects it within a custom attribute based on class (included below):
<script>
var customAttribute = document.getElementsByClassName("YOUR-CLASS-HERE");
for (element of customAttribute) {
var elementText = element.innerText;
element.parentElement.setAttribute('filter-by', elementText);
}
</script>
Edit: Depending on your setup the code may need to be modified a bit, but that should point you in the right direction
Thank you. I’m using a checkbox so I actually need to set the Attribute to a previous element, not the parent element. is that possible with JS?
Does anyone know if this is possible?
You’ll need to include your read-only link so folks can get a better idea of the setup of the project.
I’m not an JS expert by any means, but with a bit of context I may be able to suggest some modifications to the code above.