I would like to display the length of the text in my textarea. But since I don't want to build an event handler for it, I would like to try to solve this with the data-link. Unfortunately I don't find a way to do this.
<textarea id="commentText" data-link="commentText()"></textarea>
<span><span id="commentTextLength">{^{>commentText().length}}</span>/300</span>
You can simply change the expression from
commentText().lengthtocommentText()^length.See "deep linking".
In that way you make the expression update whenever there is an observable change in
commentText()itself.So you can write:
or
This works equally whether you are using a plain string value
commentText^lengthor a computed observablecommentText()^lengthas in your example.