Timeline for Why won't my Lightning Component Attributes store entered value
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 21, 2017 at 18:04 | vote | accept | Eric | ||
Feb 15, 2017 at 16:23 | comment | added | Eric | @DougChasman - Sorry for the Delay. I disabled Locker service and it DOES work as expected. I am now on Spring 17 and with locker Enabled it still does not work. With Locker disabled on Spring 17 it does work. Can you please post as an answer (maybe with expected resolution) so i can accept. | |
Jan 19, 2017 at 12:25 | comment | added | Doug Chasman | Please retry your example with Locker deactivated in your org and let me know if you see a difference in behavior. There is a long standing issue/limitation in how Locker "wraps" plain old JavaScript objects that is actively being worked on but the solution requires the use of Proxy which was not available in a number of browsers until recently so we had to use a polyfil that is not entirely accurate. The plan is to complete the current work to leverage Proxy and release it to Soring'17 as a patch. | |
Jan 19, 2017 at 4:13 | comment | added | Eric | Ok, My main goal here is to understand if setting the values with 20-30 additional lines of code is the correct way of doing it. It seems like it is. So in my JS I am getting the value from the input and directly setting the properties of the attribute then sending the JSON result to the Apex controller. Thanks for the time you put into this..... | |
Jan 19, 2017 at 4:11 | comment | added | Ashwani | @Eric I agree with you. My though is they are doing this to strict the data set between client and controller so no one can miss use or manipulate it. Because javascript has option to define properties at runtime even you can register functions whenever you want. This can break the secure environment of Salesforce where we can have several components from different vendors in a single page. | |
Jan 19, 2017 at 4:07 | comment | added | Eric | I fail to see why the input does not update the attribute. Why does one have to set it only is JS if you want to pass the class to the apex controller, especially when you can access the property directly. This makes Lightning components useless for collecting data as you have to access the elements individually to get the values to set in the attributes to pass to the controller. Whats the point. If I have an attribute bound to the input it should set the value. Just like it does if I set the value directly in the JS. Seems like a bug in the UI and Lightning input components | |
Jan 19, 2017 at 3:59 | comment | added | Ashwani |
@Eric you are expecting result as native javascript does but here framework plays the role. You won't get myTestString even the myTestStringNOTEXIST . However, I am not much clear how framework is securing elements. I am seeing this behavior from the initially ExpenseTracker app to learn lightning was introduced. Now we have LockerService also.
|
|
Jan 19, 2017 at 3:55 | comment | added | Eric |
@Ashwany - nope. I see what you are doing. but if I can access it via directly then it should stringify with the class. If I do a component.get('v.myCustomClass').mytestString = xyz then the stringify works properly. That should be no different that binding it to the input
|
|
Jan 19, 2017 at 3:53 | comment | added | Ashwani | Hope you are clear @Eric :) | |
Jan 19, 2017 at 3:49 | history | edited | Ashwani | CC BY-SA 3.0 |
added 549 characters in body
|
Jan 19, 2017 at 3:47 | comment | added | Eric | Your last example confuses. It does not output the value entered in the input like in my question it outputs undefined | |
Jan 19, 2017 at 3:46 | history | edited | Ashwani | CC BY-SA 3.0 |
added 549 characters in body
|
Jan 19, 2017 at 3:38 | comment | added | Eric |
then why does console.log(component.get('v.myCustomClass.myTestString')); work without initialization
|
|
Jan 19, 2017 at 3:34 | history | answered | Ashwani | CC BY-SA 3.0 |