You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Am I the only one having reactivity issues when binding to form elements? When I programatically set bound variables back to empty string the change is often not represented in the Input. I did find a workaround for this though by giving a custom class name to a form around the elements and resetting there. I couldn't find a solution for the select element though. Resetting the select works with const selectElement = formElement.querySelector('select') if (selectElement) { const defaultValue = selectElement.getAttribute('data-default') ;(selectElement as HTMLSelectElement).value = defaultValue || '' }
plus the reassignment of the var to empty string obviously,
but when trying to select the same option as before the bound variable is not reassigned (presumably because the Select element still assumes it is the old value before resetting it).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Am I the only one having reactivity issues when binding to form elements? When I programatically set bound variables back to empty string the change is often not represented in the Input. I did find a workaround for this though by giving a custom class name to a form around the elements and resetting there. I couldn't find a solution for the select element though. Resetting the select works with
const selectElement = formElement.querySelector('select') if (selectElement) { const defaultValue = selectElement.getAttribute('data-default') ;(selectElement as HTMLSelectElement).value = defaultValue || '' }
plus the reassignment of the var to empty string obviously,
but when trying to select the same option as before the bound variable is not reassigned (presumably because the Select element still assumes it is the old value before resetting it).
Beta Was this translation helpful? Give feedback.
All reactions