21

General Tools and settings: use Chrome + built in Dev Tools + Lightning Component Inspector be sure debug mode is enabled in your org (Setup: Lightning Components) be sure caching is disabled in your org (Setup: Session Settings -> uncheck "Enable secure and persistent browser caching to improve performance" Techniques for most common use cases (be sure ...


19

This choice was made for two reasons. We parse the Controller and Helper on the server to validate them. There are many different Java Parsers of JSON we could use, but regardless which we choose we wanted to be consistent with the client. Which wants Objects wrapped in parentheses JSON.parse("({})") vs JSON.parse("{}"). Some editors will complain that what ...


13

Currently the recommended mechanism for this is to use a Static Resource and include it in any components that need to share the same JavaScript via ltng:require (loads the library once and only once similar to requirejs).


13

I think the problem is with your doInit function. The helper is passed to the function as the third argument: doInit : function(component, event, helper){


10

You could just extend ui:button and add an attribute. Eg, <!--<c:myNewUIButton>--> <aura:component extends="ui:button"> <aura:attribute name="someAttribute" type="string" /> </aura:component> Then you should be able to use that attribute when you use the new component <c:myNewUIButton someAttribute="blah" press="{!c....


9

The various parts - controllers, helpers and the XML components themselves - are all assembled into a valid single JavaScript file that represents the component. So the pieces you edit are in a somewhat arbitrary format before that conversion. But it's a pity the JavaScript files are not valid JavaScript and so tools like http://jshint.com complain a bit. ...


9

The syntax for the second eval() misses this keyword while referring object_1 connectedCallback() { this.object_1 = "test"; console.log(" 1: " + eval("this.object_" + 1) + " 2: " + eval("this.object_" + 1)); } Playground Link : https://developer.salesforce.com/docs/component-library/tools/playground/MIpc94lRV/1/edit


8

lightning:input does a bunch of validation and other stuff, but doesn't appear to support basic events other than blur, focus, and change events. However, if you want to add some basic key detection, you can use a wrapper element: <span onkeypress="{!c.keyCheck}"> <lightning:input aura:id="body" label="" name="Body" ...


8

Is it possible to read child Web Component property from parent Aura Component? Yes you can. you are trying to call a method or a property in your LWC component from aura component the LWC way but it should be the aura way. Simple Demonstration: Parent Aura component markup <aura:component implements="flexipage:availableForAllPageTypes,flexipage:...


7

I believe the order of the params is wrong here: function(component, helper, event) Should be: function(component, event, helper)


7

Theoretically it should be possible to clear values on force:inputField. But in your specific case it seems not to work as expected. force:inputField is a smart field component operating on different field types differently. For bound plain text fields the reset works while for lookups attribute updates are not rendered correctly. Known Weakpoints There ...


6

It is a JavaScript object - the JSON has already been parsed. To inspect simple JavaScript objects use JSON.stringify: console.log('currency data is:' + JSON.stringify(actionResult.getReturnValue())); This will walk around the object graph - across arrays and nested objects - and output each object found in string format. (The server takes Apex objects, ...


6

The controller of a component has no this context, only the helper does. There are ways of calling one method from another via something like: let action = component.get("c.cbFunction"); $A.enqueueAction(action); But you can't pass parameters, and the event parameter ends up being null, so overall, it doesn't work particularly well. Instead, whenever you ...


6

Lightning Component Framework is optimized for performance. So unless and until you have things really going bad, you should be good if you implement your component using Lightning Components Performance Best Practices. Then Lightning component framework is all about building rich UI applications utilizing more of client side features. So if you really don’...


6

Sure, you can dynamically call aura method accessing a function through the bracket notation []: var methodName = 'myMethod' ; var childCmp = component.find('childCmp'); childCmp[methodName]();


5

Instead of doing things in init, try it in afterRenderer. Reason is that init is called long before DOM availability, which might cause a timing issue. Incase of afterRenderer it is called only after the DOM is rendered in the view.


5

Your callback has an empty function body, because the second parentheses closes the function body prematurely. Honestly, I'm surprised this compiled at all. It should look more like: getMyContacts : function(cmp) { var action = cmp.get("c.getContacts"); action.setCallback(this,function(response) { var status = response.getStatus(); ...


5

The framework provides a format function for this purpose e.g. with the label: Hello {0} and {1} the code could be: {!format($Label.mySection.myLabel, v.attribute1, v.attribute2)}


5

Logan, I just happen to have a sample of Fullcalendar which displays events. But heads up .. it is not locker compatible. even though I have used ( Full Calendar: 3.1.0 & jQuery 2.2.4 ) as recommended in the non-exhaustive list of libs. When locker service is enabled: You would get the following the error This is quite an ongoing issue, ...


5

Just a different way to slice the pie I guess but this puts the pieces where they belong IMHO and leave lightning in lightning and classic in classic Lightning App <aura:application access="GLOBAL" extends="ltng:outApp" description="exampleApp"> <!-- Load the navigation events in the force namespace. --> <aura:dependency resource="...


5

I did the following and it worked just fine. So start here and add in stuff till it breaks. This is essentially what you posted since the rest of your code is missing. Parent Component <aura:component description="parentComponent" access="global" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:...


5

Looks like your event handler declaration is causing the problem. <aura:handler name="QuestionAddedEvent" value="{!this}" action="{! c.reloadQuestions }"/> You should not be using value="{!this}", as this would try to handle component initialisation. I am guessing it is conflicting with you doInit handler throwing the error. There must be only one ...


5

I'm pretty sure its just because your setParam should be setParams(---) instead. documented example at Calling a Server-Side Action action.setParams({ firstName : cmp.get("v.firstName") });


5

You are turning your array into a string: let questionArray = JSON.stringify(component.get("v.questions")); // ^^^^^^^^^^^^^^^ ^ If v.questions is an array, just cache it as such. Also use const since you don't reassign: const questionArray = component.get("v.questions");


5

setParam expects two parameters, a name and the value to set. Either use setParams, or use the correct setParam syntax: action2.setParam("openOpps", oppList); It is generally not necessary to JSON.stringify yourself, and you should avoid doing so when possible.


5

Aside from Jayant's excellent answer, it's worth noting that JavaScript is faster than Apex, hands-down. Whenever Visualforce started to have issues with rendering a page, the immediate solution is to use a client-side framework, as demonstrated in this answer. In other words, the general advice is to avoid using Apex, because it is slower than client-side ...


4

The rule of thumb in lightning is never name your methods with the same name . 1.Make sure your apex controller methods is never similar to your one of the JS controller methods name 2.Similarly make sure your helper methods name are not similar to the Javascript controller methods name 3.Also make sure helper method names do not conflict with apex ...


4

There are some issues with the client-side javascript controller that you wrote for your component. Here is the corrected code: ({ getName : function(component, event, helper) { var action = component.get("c.getAccountName"); // your code as extra closing in the following line as well action.setCallback(this,function(response){ ...


4

The accepted solution will not solve your problem at the moment if Lightning Locker is enabled. In the button press handler, if I try to call event.getSource() it throws an uncaught exception Uncaught TypeError: Cannot redefine property: addHandler(…). I am guessing this is a Locker issue. So you can extend the component but you can't get a reference to it ...


4

Add an aura:id to the <ui:button /> component, then find the button by it. component: <ui:button aura:id="btn" label="A" press="{!c.disableMe}"/> <ui:button aura:id="btn" label="B" press="{!c.disableMe}"/> <ui:button aura:id="btn" label="Enable them all!!!" press="{!c.myClearButtonClicked}"/> ...


Only top voted, non community-wiki answers of a minimum length are eligible