Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [javascript-controller]

A controller is a JavaScript Object, created by a standard JavaScript object constructor. In the Aura Framework, the JavaScript controller is client-side.

Filter by
Sorted by
Tagged with
30 votes
3 answers
27k views

How do I debug my lightning component?

I have seen and read many posts in regards lightning component errors and realized there are no questions actually asking how to debug them. I recently stumbled upon: How do I start to debug my own ...
glls's user avatar
  • 20.2k
17 votes
3 answers
1k views

What are the outer parentheses in Lightning controllers?

In every Lightning controller you have these outer parentheses wrapping the actual object: ({ getInput : function(cmp, evt) { var myName = cmp.find("name").get("v.value"); var ...
Semmel's user avatar
  • 2,497
17 votes
2 answers
1k views

Sharing JavaScript between multiple Lightning Components

In a Lightning Component we have the notion of a JavaScript controller and a helper. We can use the helper to call code from the JavaScript controller that is shared between functions, so we can ...
Folkert's user avatar
  • 2,712
16 votes
4 answers
28k views

Get records in Lightning web components without APEX

import { LightningElement, track, api, wire } from 'lwc'; import { getRecord } from 'lightning/uiRecordApi'; const FIELDS_SOLICITUD = [ 'DCABM_obj_solicitudABM__c.DCABM_fld_aplicacionSolicitud__c'...
Alex M.'s user avatar
  • 534
14 votes
3 answers
3k views

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

Is it possible to see if a user is in Comfy or Compact display density in a lightning controller? This is a new feature since Winter '19 and I cant find any documentation about this.
Robin Weymans's user avatar
14 votes
2 answers
4k views

Is it possible to clear force:inputField?

I have a force:inputField field on my lightning component acting as a lookup. It is working fine: <force:inputField aura:id="segmentid" value="{!v.campaign.Survey__c}"/> <ui:button press="{!...
Ross Bassett's user avatar
8 votes
1 answer
4k views

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

I have an issue working on integration between Aura Component and Lightning Web Component. I have one nested Lightning Web Component in an Lightning Component. When I try to access the child I get ...
cloma's user avatar
  • 83
7 votes
1 answer
3k views

eval() in Lightning Web Components

This code works in JS <script> let object_1 = "value"; window.console.log(eval("object_" + 1)); </script> But I try to do it in LWC and I get the error that the variable is "...
Alex M.'s user avatar
  • 534
7 votes
1 answer
754 views

Can we use the event's attribute "path" in Lightning?

I've been working on a pretty complicated component, and I've had all kinds of trouble simply trying to identify which element is currently being used. After all sorts of experiments, I found a really ...
sfdcfox's user avatar
  • 494k
6 votes
2 answers
1k views

Locker Service and Fullcalendar.io

I have seen that there have already been some questions regarding the open source Fullcalendar.io and the various libraries associated with it, and the strict requirements of Locker Service, but I was ...
Logan's user avatar
  • 330
6 votes
1 answer
295 views

Help Interpret Peculiar Way of Handling SUCCESS and ERROR in Lightning Callback

I didn't write but rather I'm reviewing the following Lightning JS function: InitializeComponent : function (component) { var recId = component.get("v.recordId"); var action = ...
Gabriel Rivera's user avatar
5 votes
1 answer
9k views

Helper method error: says is "Not a function"

I'm trying to implement a helper method in a Lightning component, but the error that comes up is: "This page has an error. You might just need to refresh it. Error during init [Action failed: c:...
Lachlan B's user avatar
  • 313
5 votes
2 answers
6k views

lightning:input help -- keyCode

I'm seeking more info on lightning:input for use in a Lightning Component. What I want to do is have the input text field submit when the user presses the Enter key. However, the Enter key seems to ...
PatMcClellan__c's user avatar
5 votes
3 answers
2k views

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

I have several buttons which I need to assign to the same handler, but each one will act on a different value. I would LIKE to do something like the code at the end of this post, but I cannot find a ...
loneboat's user avatar
  • 387
5 votes
2 answers
735 views

Extracting a callback function

I have the following code in my controller: doInit: function(component, event, helper) { // Create the action var action = component.get("c.getExpenses"); // Add callback behavior for ...
user1786037's user avatar
5 votes
2 answers
16k views

The first parameter of loadScript() and loadStyle() must be an LWC component

I have a strange problem with the component and I don't know what more can i do, I'm having this problem whenever I put the lwc inside the recordPage of a custom object but in a standard recordPage ...
Alex M.'s user avatar
  • 534
5 votes
2 answers
1k views

Packaging custom labels used in lightning helpers and controllers

So in our lightning code base we usually refer to labels from js helpers and controllers as the following (it's static reference, not dynamic one): $A.get("$Label.c....
wesaw's user avatar
  • 3,080
5 votes
2 answers
159 views

How to preserve string with newlines passing from LWC to VF controller for PDF rendering

I have a Lightning Web Component (LWC) which takes a text input from the user. The text input is entered via a lightning-textarea, i.e. can also contain text with newlines. The LWC contains an iframe ...
HeXor's user avatar
  • 287
5 votes
1 answer
5k views

Dynamic Button Icons in a Data Table Similar to Dynamic Actions in a Data Table

It's possible to have actions for each row in a data table that change depending on the contents of the rows (that are changed by those very actions). For example: The component reference provides ...
Gabriel Rivera's user avatar
5 votes
1 answer
357 views

JavaScript function failing after spring'18 release [closed]

JavaScript function failing after spring'18 release. event.currentTarget.id event.target lightning component <aura:component implements="force:appHostable" access="global"> <div class="...
Venky's user avatar
  • 634
5 votes
1 answer
2k views

Can't get object property in lightning component controller

I am trying to access JS object properties in the client controller. I get undefined if I try access it by name. But I see the properties if I log the whole object. Something I am missing? var ...
Allen Mann's user avatar
  • 1,092
5 votes
2 answers
3k views

How to store a dynamically created component in attribute of parent component using Aura.component[]?

Scenario: Re-use of dynamically created components by storing them in Aura.component[] attribute in parent component. Use-case I am creating dynamic components in a parent component, and am ...
Sarang's user avatar
  • 2,585
5 votes
0 answers
329 views

Passing a variable to lightning component through snapin chat

I have a snapin chat component embedded on our custom application (not salesforce or a community). I'm trying to allow a parameter to pass through to my lightning component for use in the prechat ...
zainogj's user avatar
  • 1,854
5 votes
2 answers
11k views

How do you set a default value on lightning component force:inputField which is a lookup?

I have a lightning component (Summer 16) which contains a "Task" attribute as follows: <aura:attribute name="task" type="Task" default="{ 'sobjectType': 'Task' }"/> Further down the page, ...
Brett's user avatar
  • 149
4 votes
2 answers
30k views

Lightning response.getReturnValue() question

I did not find much info on the "response.getReturnValue" function and what it exactly returns. I understand that this is the function that must be used when a Client Side JS controller calls a Server ...
SFDC Dev 27's user avatar
4 votes
3 answers
2k views

Spread Operator Usage in LwC

I have a javascript related question. I have the piece of code using a spread operator var arrObj = [{ name : "m"}, { name : "mb"}]; var arrObj1 = [...arrObj]; console.log(arrObj1);...
Madhurima's user avatar
  • 1,395
4 votes
2 answers
29k views

LWC: Inside an HTML template for-loop, set loop variable property to new user-typed input element value?

I'm trying to write a Lightning Web Component (yay, first one). Still in the "proof of concept; can I get user input to propagate around the page?" stage. I have a List<MyApexWrapperClass> ...
k..'s user avatar
  • 1,217
4 votes
2 answers
12k views

Scroll Page to top onClick of a button in Saleforce1

I have a problem scrolling to the top of a lightning component page in Salesforce1. I have tried using window.scrollTo(0,0); Added the below attribute in the button tag oncomplete="window....
Brav's user avatar
  • 820
4 votes
1 answer
3k views

Array.filter() in Lightning Components

I'm trying to filter through an array of objects in a controller using the JavaScript filter() method. I get an error, however, that says, Uncaught Action failed: c:QuestionIteration$controller$...
Josh Stigall's user avatar
4 votes
1 answer
874 views

Set dynamically Lightning Component Attributes

Currently I develop a Lightning Component, which should show record details based on specific record field values. Therefore I want to set dynamically component attributes based on some record values. ...
Michael.Saupe's user avatar
4 votes
1 answer
10k views

Lightning - Show/hide section function div with same ids triggering at the same time when one div is clicked

When a div is clicked i want to show some information. I have two divs with the same ids referring the same function. I want the event to be triggered only when the corresponding div is clicked. It is ...
ləːnə's user avatar
  • 289
4 votes
2 answers
3k views

Convert the any locale date format to US date format in Javascript lightning

I have been struggling to change the date format to US locale time. I tried so many methods but if fails at some or other scenario. The issue is I cannot say which Locale the client will be using. ...
Nupur Bhagat's user avatar
3 votes
2 answers
4k views

urlEvent is undefined

We have below code being called from Cancel button on a Lightning component. We have used this lightning component on VF page. navHome : function (component, event, helper) { var urlEvent = $A....
Pasan Eeriyagama's user avatar
3 votes
2 answers
6k views

How to load and use external library?

I don't know how to use the library of Pagination in a lightning web component but I can't use the example method: $('#demo').pagination({ dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195], ...
Alex M.'s user avatar
  • 534
3 votes
2 answers
6k views

Multiple lightning:recordEditForm

I have a quick way of entering multiple records where user can add rows(record) to add. I am using lightning:recordEditForm component in aura:iteration. When i add multiple rows everything is working ...
Nikhil Prashar's user avatar
3 votes
1 answer
2k views

Passing sObject List from Client Controller to Server Controller (Lightning Components)

Seems like I'm not being able to pass a sObject list to my server-side controller. I've seen articles and other forum answers that propose using JSON.stringify. I've tried that method, but my server-...
fdc's user avatar
  • 124
3 votes
2 answers
11k views

Get lightning:inputField value in javascript controller

I have following code in component which is called by another lightning component from aura:iteration. I want to get value from lightning inputField when it is changed in the javascript controller and ...
Anish Shrestha's user avatar
3 votes
1 answer
4k views

Param passed from Lightning Component to Apex controller is read as null

I am trying to pass a string from my Lightning Component to an Apex controller, but when it is received by the Controller it is interpreted as null. The controller works fine and is returning data, ...
Thom B's user avatar
  • 75
3 votes
1 answer
5k views

$A.util.removeClass not working in some cases

On init of a component, I want to hide an element lightning:buttonIcon if some condition is satisfied(see controller code). In this case it is getting satisfied and I am reaching the code where ...
Sarang's user avatar
  • 2,585
3 votes
2 answers
2k views

unable to get index var from lightning:select option (undefined)

component.cmp <lightning:select name="Version" label="Select a version" disabled="true" onchange="{!c.itemsChange}"> <option value="">choose one...</option> ...
glls's user avatar
  • 20.2k
3 votes
1 answer
1k views

Visualforce not defined

i was doing a page/script/controller functionality just see how it works, and for some reason i get the error "Visualforce is not defined". From what i got searching, this error shows when you dont ...
Vinicius Souza's user avatar
3 votes
1 answer
32k views

Lightning Component: Cannot read property 'get' of undefined

I've read through the different posts regarding this error, and for the life of me I cannot figure out why it's not working right.... I would really appreciate some help. I've checked to make sure ...
Genko's user avatar
  • 636
3 votes
2 answers
572 views

How to read parent APEX page element value inside a Lightning component?

We have a VF page with Lightning components on it. we need to read a User input (i.e. Apex control value) inside my lightning component JS controller. It seems that, document.getElementById("...
Pasan Eeriyagama's user avatar
3 votes
1 answer
594 views

DOM modifications from controller in lightning

While reading this article I met the following rule: Do not modify DOM in Controller. If you modify DOM in Controller it will call renderer method which will end in no result. The article looks ...
iloveseven's user avatar
  • 1,115
3 votes
1 answer
1k views

Can actions/methods in the client controller (Javascript) and server controller (APEX) have identical names?

In the documentation I found the following tip: Use unique names for client-side and server-side actions in a component. A JavaScript function (client-side action) with the same name as a server-side ...
loneboat's user avatar
  • 387
3 votes
1 answer
205 views

Simple Apex controller function never executing

I have a standard Aura Lightning Component with onChange handler, Javascript controller and Apex controller but even though everything seems to be fine, the server controller method is never called. ...
UO Man's user avatar
  • 80
3 votes
0 answers
1k views

Cannot read property 'appendChild' of undefined

I want to show the geoposition on a leaflet map lightning component. I enter an Id and get geolocation data accordingly. When I first enter an Id everything works fine, for the second time it shows ...
Tokow's user avatar
  • 31
2 votes
2 answers
8k views

Component Initilization Error: cannot read property 'g'

Everything was working fine with this component a couple days ago. Then I added an event and now I'm getting a strange error: Uncaught Component class instance initialization error [Cannot read ...
MadMax's user avatar
  • 1,000
2 votes
2 answers
1k views

How to repeatedly poll a server-side controller for an action in a Lightning Component?

There's a Lightning Component with a button. Its onClick attribute points to a client-side controller's function. It invokes helper's function which I would like to start a polling routine to a server-...
Przemysław Długoszewski-Tamoń's user avatar
2 votes
3 answers
22k views

aura: method to call child component controller function not working

Using <aura:method>, I am not able to call child component controller function from parent controller. Below code. Parent Component <aura:component access="global" implements="force:...
Brav's user avatar
  • 820

1
2 3 4 5
7