32 votes
Accepted

How do I debug my lightning component?

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 ...
Christian Menzinger's user avatar
19 votes
Accepted

What are the outer parentheses in Lightning controllers?

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 ...
Kris Gray's user avatar
  • 3,106
18 votes
Accepted

Helper method error: says is "Not a function"

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){
martin's user avatar
  • 12.6k
14 votes
Accepted

Sharing JavaScript between multiple Lightning Components

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 ...
Doug Chasman's user avatar
  • 10.1k
12 votes
Accepted

lightning:input help -- keyCode

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, ...
sfdcfox's user avatar
  • 481k
12 votes
Accepted

Lightning response.getReturnValue() question

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()))...
Keith C's user avatar
  • 135k
10 votes
Accepted

How to add extra data to a ui:button in a Lightning Component?

You could just extend ui:button and add an attribute. Eg, <!--<c:myNewUIButton>--> <aura:component extends="ui:button"> <aura:attribute name="someAttribute" type="string" /&...
Caspar Harmer's user avatar
10 votes
Accepted

How to access child Web Component property from parent Aura Component controller?

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 ...
RedDevil's user avatar
  • 7,765
9 votes

What are the outer parentheses in Lightning controllers?

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 ...
Keith C's user avatar
  • 135k
9 votes
Accepted

eval() in Lightning Web Components

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: " + ...
Pranay Jaiswal's user avatar
8 votes
Accepted

How to get the display density in a lightning components controller?

You can get Display density information using Salesforce User Interface API. This Link will help you. I don't think you can directly access Salesforce UI-API from Lightning controller, but you can use ...
Arun's user avatar
  • 498
8 votes
Accepted

How to load and use external library?

Using webcomponents and Jquery together can get bit tricky . Here is how i approached this and got it working 1.Create a zip file that has latest jquery.min.js , pagination.js and pagination.css ...
Mohith Shrivastava's user avatar
8 votes

Get records in Lightning web components without APEX

Another Update: With Spring '23, there is a pilot for the GraphQL wire adapter. This would allow you to perform a query on any UI API enabled object and get the records without needing apex. import { ...
Kris Goncalves's user avatar
7 votes
Accepted

Helper function not getting recognised intermittently

I believe the order of the params is wrong here: function(component, helper, event) Should be: function(component, event, helper)
Eric's user avatar
  • 54k
6 votes
Accepted

lightning callback not firing

According to this post, "a javascript method name in a component controller can never be the same name in an apex lightning controller": Enqueued action not executed in Lightning Component Just need ...
Instread's user avatar
  • 633
6 votes

aura: method to call child component controller function not working

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:...
Eric's user avatar
  • 54k
6 votes
Accepted

Component Initilization Error: cannot read property 'g'

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="{!...
Sumuga's user avatar
  • 2,119
6 votes
Accepted

Extracting a callback function

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....
sfdcfox's user avatar
  • 481k
6 votes
Accepted

Does more logic on Client side reduces the lightning performance?

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 ...
Jayant Das's user avatar
  • 30.3k
6 votes
Accepted

Lighting Components: Dynamically Call Aura Method

Sure, you can dynamically call aura method accessing a function through the bracket notation []: var methodName = 'myMethod' ; var childCmp = component.find('childCmp'); childCmp[methodName]();
Oleh Berehovskyi's user avatar
6 votes
Accepted

LWC update toggle checked/unchecked attribute from JS

Just bind the checked attribute to javascript property. <lightning-input data-id="toggle2" type="toggle" label="TOGGLE2" checked={checked} message-toggle-active="" message-toggle-inactive="">&...
Rahul Gawale's user avatar
  • 11.9k
6 votes

Spread Operator Usage in LwC

The spread operator is a shallow copy operation. That means that while the arrays are separate objects, they both refer to the same element in every index. Let's provide a very simple example that ...
sfdcfox's user avatar
  • 481k
5 votes
Accepted

$A.util.removeClass not working in some cases

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 ...
Praveen's user avatar
  • 10.1k
5 votes

action.setCallBack() - call Back failed in lightning application

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 : ...
sfdcfox's user avatar
  • 481k
5 votes
Accepted

How to add dynamic variable to custom label in lightning javascript helper class

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)}
Keith C's user avatar
  • 135k
5 votes
Accepted

Locker Service and Fullcalendar.io

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 ...
Sumuga's user avatar
  • 2,119
5 votes

urlEvent is undefined

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="...
Eric's user avatar
  • 54k
5 votes
Accepted

Lightning addEventListener to li

I'm going to assume that you have more than one <li> item for this answer. You need to run this code in the renderer (or use the newly added event for Summer 17 - we'll use the renderer for now ...
Caspar Harmer's user avatar
5 votes
Accepted

Is it possible to clear force:inputField?

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 ...
Uwe Heim's user avatar
  • 28.3k
5 votes

Scroll Page to top onClick of a button in Saleforce1

The propper syntax for scrollTo according to the documentation: scrollTo('custom', 0, 0); or scrollTo('top'); I reproduced it, called the methods as documented and was also not able to scroll to top,...
itsmebasti's user avatar
  • 6,359

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