I am trying to set the value of an Input widget via JavaScript in Appsmith, but it seems like this feature is not yet available. I was told to save the value to the Appsmith store and bind it to the Input widget's Default Text property instead. However, I am having trouble triggering the value and resetting the Input widget to always contain the current value.
UPDATE!
Soon we will be releasing Widget Property Setters, which will allow setting widget properties directly with actions or JS, using methods like Input1.setText()
, Button1.setLabel()
, etc.
Setting the value of an Input widget via JavaScript is currently not possible in Appsmith (for now). However, you can save the value to the Appsmith store using the storeValue()
function, and then bind the value from the store to the Input widget's Default Text
property using appsmith.store.varname
.
You can also use the resetWidget()
function to reset the Input widget to its default value, the clearStore()
function (to clear ALL values), or storeValue("varname", undefined)
.
Here's an example of how to save the value to the store and bind it to the Input widget's Default Text property:
// save value to store
storeValue('varname', 'Test Text')
// bind value from store to Input widget
{{ appsmith.store.varname }}
And here's an example of how to reset the Input widget:
// reset Input widget
resetWidget('Input1')