Timeline for Why won't my Lightning Component Attributes store entered value
Current License: CC BY-SA 3.0
25 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 21, 2017 at 18:04 | vote | accept | Eric | ||
Mar 21, 2017 at 17:48 | answer | added | TrevorBliss | timeline score: 6 | |
Feb 15, 2017 at 16:25 | history | edited | Eric | CC BY-SA 3.0 |
added 260 characters in body; edited tags
|
Feb 8, 2017 at 22:05 | history | edited | Eric | CC BY-SA 3.0 |
added 7 characters in body
|
Feb 8, 2017 at 21:59 | history | edited | Eric | CC BY-SA 3.0 |
added 874 characters in body
|
Jan 19, 2017 at 4:10 | history | edited | Eric | CC BY-SA 3.0 |
added 38 characters in body
|
Jan 19, 2017 at 4:04 | history | edited | Eric | CC BY-SA 3.0 |
added 695 characters in body
|
Jan 19, 2017 at 3:57 | comment | added | Eric |
@Ashwani No but console.log(component.get('v.myCustomClass.myTestString)); does. And if I set the value using component.get('v.myCustomClass').myTestString = 'xyz' then the JSON.stringify(component.get('v.myCustomClass'); works properly. That should be no different than binding it to the input IMHO
|
|
Jan 19, 2017 at 3:54 | comment | added | Ashwani | This will not work "console.log(component.get('v.myCustomClass).myTestString)); | |
Jan 19, 2017 at 3:51 | comment | added | Eric | Ahh I see... You would think if the property is set the it would at least output when JSON the attribute....Especially if you can access it directly | |
Jan 19, 2017 at 3:50 | comment | added | Ashwani |
@Eric may be a typo mistake as I edited the comment multiple time because of trailing OOO . Try the example in my answer. it works
|
|
Jan 19, 2017 at 3:46 | comment | added | Eric |
@Ashwani - Yea, I get 1.1 undefined . It does not give met the value of the input. When accessing as in my question anything I enter in the input gets output properly when accessing the property directly but when accessing just the class it gets {}
|
|
Jan 19, 2017 at 3:43 | comment | added | Ashwani |
There is a framework logic. Only you know there is myCustomClass.myTestString but framework doesn't know. Take the example: set the input as ` <ui:inputText aura:id="firstInput" updateOn="keyup" keyup="{!c.logMe}" requiredIndicatorClass="slds-required" required="true" value="{!v.myCustomClass.myTestStringNOOOOO}" placeholder="Enter Me" class="slds-input"/>` and access it as console.log( component.get('v.myCustomClass.myTestStringNOOOOO')); You will get the value but it is not the variable in controller.
|
|
Jan 19, 2017 at 3:41 | history | edited | Eric | CC BY-SA 3.0 |
added 295 characters in body
|
Jan 19, 2017 at 3:39 | comment | added | Eric |
@Ashwani - May be correct, but accessing the property directly via console.log(component.get('v.myCustomClass.myTestString')); does output a where just using v.mycustomClass outputs {} . Something weird here
|
|
Jan 19, 2017 at 3:37 | comment | added | Ashwani | You will have to define it because Lightning doesn't know if there is such property exist on not (it is undefined). Because of locker service it won't even let you defined new property. | |
Jan 19, 2017 at 3:37 | comment | added | Eric | @Salesforcesmarty you are correct, I just verified that. Wierd | |
Jan 19, 2017 at 3:34 | comment | added | Salesforcesmarty | This is interesting, when I am logging "component.get('v.myCustomClass.myTestString')", it gives the value a, however when logging the class, it returns empty. Let me have a look. | |
Jan 19, 2017 at 3:34 | answer | added | Ashwani | timeline score: 4 | |
Jan 19, 2017 at 3:33 | comment | added | Eric | @Ashwani - yup, the initial one works, the non initial does not. thats what I showed in my example. I do not expect to have to do it like the initial bu setting empty string for all properties in the class. | |
Jan 19, 2017 at 3:29 | comment | added | Ashwani |
console.log(JSON.stringify(component.get('v.myCustomClassInitial'))); is working fine for me
|
|
Jan 19, 2017 at 3:22 | comment | added | Eric | No, when you type values in the first box it does not get set in the attribute. When you type values in the second box the attribute updates. Would like to have the attribute update without have to initialize all properties in the class to an empty string | |
Jan 19, 2017 at 3:21 | comment | added | Salesforcesmarty | Sorry I couldn't understand your question properly. Did you mean that when the component loads, in the second input box "Initial" value is not prepopulated? | |
Jan 19, 2017 at 3:09 | history | edited | Eric | CC BY-SA 3.0 |
added 2 characters in body
|
Jan 19, 2017 at 2:29 | history | asked | Eric | CC BY-SA 3.0 |