01-01-2023 12:25
01-01-2023 12:25
Hi! I am working on a Fitbit app that will retrieve data (school lunch menu) from an external API. I implemented an error screen, and since error messages have different lengths, I thought I'd use a #dynamic-textarea for the error message.
However, I'm running into an issue. My code for the dynamic text area is:
<use href="#dynamic-textarea" fill="white">
<set href="text" attributeName="text-buffer" to=""/>
<set href="text" attributeName="text-anchor" to="middle"/>
<set href="text" attributeName="id" to="error-message"/>
</use>I tried to access the "error-message" ID via code and change it, but with no success:
document.getElementById("error-message")["text-buffer"] = messageI also tried
document.getElementById("error-message").text = messageAny help is appreciated!
Answered! Go to the Best Answer.
Best Answer01-01-2023 12:58
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
01-01-2023 12:58
I think there are a few issues.
Try this (untested):
<svg>
<use id='myErrorMessage' href="#dynamic-textarea" fill="white">
<set href="#text" attributeName="text-buffer" to="My error"/>
<set href="#text" attributeName="text-anchor" to="middle"/>
<set href="#text" attributeName="text-length" to="64"/>
</use>
</svg>
const el = document.getElementById('myErrorMessage')
console.log(`${el.text}`);
el.text = 'a new error'
Best Answer01-01-2023 12:58
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
01-01-2023 12:58
I think there are a few issues.
Try this (untested):
<svg>
<use id='myErrorMessage' href="#dynamic-textarea" fill="white">
<set href="#text" attributeName="text-buffer" to="My error"/>
<set href="#text" attributeName="text-anchor" to="middle"/>
<set href="#text" attributeName="text-length" to="64"/>
</use>
</svg>
const el = document.getElementById('myErrorMessage')
console.log(`${el.text}`);
el.text = 'a new error'
Best Answer01-02-2023 08:11
01-02-2023 08:11
Hi!
I tried your solution and it worked! Thanks a lot. I thought I tried the proposed solution but apparently, I didn't.
Side note: It worked for me on other components to not use # in href, but I changed all my components to use it. Thanks!