3

I have one input field type number

<lightning:input type="number" aura:id="userId" name="userId" label="User Id" 
value="{!v.MyUser.userid__c}"  required="true" maxlength="10"/>

After my operation I need to reset the input field.So I am resetting the object field

component.set("v.MyUser", 
                {'sobjectType': 'Myuser__c',
                     'Name': '',
                     'userid__c': 0
                });

The field value is initialized to 0. But I need to clear the field.

I have tried

component.find("userId").set('v.value','');

also, but once I click the field it get reset, otheriwse it still displays the old value.

  • I am facing the same problem, somehow the ui does not refresh with the new value – Itai Shmida Nov 13 '16 at 8:34
2

We ran into the same issue and what we did was put the number field inside an aura if and used an attribute to hide and show it again and it became blank. Since aura-if removes the element from the dom and when rendering it again it recreates it so the field appears blank again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.