1

I have declared sobject in lightning component as

<aura:attribute name="newStudent" type="Student__c" 
                default="{'sobjectType':'Student__c',
                         'Name':'',
                         'Marks':0,
                         'OptionValues__c':' ',

                         }"             
                />

 <div class="slds-form-element" id="optionValue">

                    <label class="slds-form-element__label ques" for="levels" >Option Values</label>
                    <ui:inputTextArea class="dynamic"  aura:id="Option values" value="{!v.newStudent.OptionValues__c}" change="{!c.changeOptionValue}"/>
                </div>
                <br/>

I am accessing this field in controller as:

changeOptionValue : function(component,helper,event)
{
    var newStudent=component.get("v.newStudent");
   var optionValues=newStudent.OptionValues__c;
   console.log('optionValues'+optionValues);
}

Here on change of option value I want to do some operations on new value of optionValue field of newStudent object.But I am getting the old value of option value.This was working in winter release but it is not working in summer 16. Is their any another way to do this same..

  • Are you expecting 'changeOptionValue' to be called after every letter change in the input, or only once after the input field is out of focus ?, just to clarify – Gopal Rao Jun 20 '16 at 10:52
  • only once @GopalRao – Raseeka Jun 20 '16 at 11:38
1

Yes, binding the 'inputTextArea' value directly with an object's field(any object even JSON) is causing this issue. The value is getting updated only the first time. Anyhow, the other way that works fine is, instead of binding the input directly with an Object's field, define an extra attribute(a dummy) which represents the object's field and bind the input with this. for example :

    <aura:attribute name="newStudent" type="Account" 
                        default="{'sobjectType':'Account',
                                 'Name':'Dickenson plc',
                                 'AccountNumber':'12345',
                                 }"             
                        />
        <aura:attribute name="extraStr" type="String" default="12345" />
        <div class="slds-form-element" id="optionValue">
            <label class="slds-form-element__label ques" for="levels">Option Values</label>
            <ui:inputTextArea class="dynamic" updateOn="change" aura:id="Option values" value="{!v.extraStr}" change="{!c.changeOptionValue}"/>
        </div>
</aura:component>

in the above case ExtraStr is the dummy, and in the controller you can assign it to object (depending on your need):

changeOptionValue : function(component,helper,event)
{
    var newStudent=component.get("v.newStudent");
    var extraStr = component.get("v.extraStr");
    newStudent.AccountNumber = extraStr ;
    console.log('optionValues '+ extraStr);
},
  • @Raseeka are you still facing this issue ? did this approach work for you ? – Gopal Rao Jun 22 '16 at 8:55

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.