Mr. Han, after I click the close button, the pop-up window reopens, and the data inside is still there. Can this be cleared by reopening?
Clear when you click close
Just can't get rid of it clearly? how to clear
Is it possible to clear the content of the form with attributes?
$page.widgets.id**.value = "" can be cleared
We often have this kind of demand in daily life, click on a pop-up box, enter content, and clear the input content after the pop-up box is closed. Some fans asked if there is a way to use it directly? Similar to the reset method of the form, at present, the built-in method that does not provide components in Weitai can clear the content of the form at one time, which requires us to implement it with code.
If we want to restore the scene of this student, we first need to build a pop-up window component
Some students asked how to add content to the pop-up window component. The pop-up window component is divided into two slots, one is a button slot, and the other is a content slot. The button slot allows us to decide which buttons to place, and the content slot can place various components. Generally, we can place form components, such as the single-line input and image upload components that students asked at the beginning.
The question asked by this student is to click the close button to clear the input content of the form component. We must first solve the problem of how to close the window.
Now the pop-up window component has provided the built-in method of the component to realize the closing and opening of the window. In the event in the lower right corner, we choose to click the close button
In the pop-up window, select the pop-up window
In the next interface we choose to close the window
We want to clear the content of the form when it is closed. This involves a chain call problem. We can continue to call the method when the switch state is successful. The selected action is the Javascript code to choose to add a
new
method, enter the method name, and the method. Write the content to clear the input content of the form component.
The code is what I started to talk about by resetting the input content attribute of the component to clear it. First, you need to find the component Id of the component. The
reset statement is
$page.widgets.formInput1.value = ""
Here to explain this sentence uses the concept of javascript expression, operand 1 operator operand 2, the equal sign means assignment, it will assign the value of operand 2 to operand 1, so by assigning an empty string The purpose of clearing the content of the form is achieved.
full code
$page.widgets.formInput1.value = ""
$page.widgets.formImageUploader1.value=""
After setting, we add a button component, and let the window open again when clicked
final effect