Questions tagged [dom]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
22
votes
3answers
1k views

force:navigateToComponent not loading component in Summer '17 | DOM repetition issue in Summer '17

I'm using force:navigateToComponent to navigate to a different component on click. On the first click, it navigates to the component and everything is successfully loaded. When pressing back button ...
0
votes
1answer
29 views

dataLayer in Lightning component

Can someone tell me how can I access DOM dataLayer in lightning component controller? I'm using like this but its not pushing into DOM dataLayer window.dataLayer = window.dataLayer || []; ...
2
votes
1answer
1k views

How can I test the click of a button that calls an Apex method, and makes the component show a toast?

The component itself, when loaded, queries some data from the database. Then, depending on what it finds, loads the specific template. One of those has a button, which will call the server again, and ...
2
votes
1answer
2k views

Salesforce generating a div with padding when using Lightning Component

I am using lightning component to override my standard 'new' action on custom object. Problem is: Salesforce is generating a DOM element where it puts my lightning component's code. This div has ...
1
vote
1answer
45 views

How to store state and conditionally render UI of a VF component in JS

I am enhancing the app setup application to replicate Setup Assistant UI. To build the expandable setup UI. I need to store the state(Expanded/Collapsed) of the component. Normally in Aura/LWC, I ...
1
vote
2answers
171 views

DisconnectedCallback in LWC

I want to do some DML operation when my lwc is removed from the DOM, so can anyone please confirm if disconnected callback will run on all below scenario on close tab. on browser close. got ...
0
votes
1answer
42 views

How is the <template> tag used in lwc different from one used in web components?

According to usage of <template> in web components: The elements under template won't appear in your page until you grab a reference to it with JavaScript and then append it to the DOM For ...
2
votes
1answer
392 views

Visualforce 'onChange' DOM event not firing when dependent picklist changes to default value

I have a VF page where several field's required attribute is dynamically tied to the value selected on a picklist: <apex:outputPanel id="idAccountField"> <apex:inputfield value="{!...
0
votes
1answer
56 views

Lwc- problem to get id as it changes with random no. inside external Js

Hi all I am trying to access the id of a div in lwc with the help external js(static resource) where code is like document.getElementById("createsulightning"); for <div id="createsulightning">&...
3
votes
0answers
641 views

What is all that <!--render facet: 5:0--> thing in Lightning Pages about?

I know it's a "who cares" question, but somehow I care and I wanted to have this documented somewhere in the WWW :) In Lightning Pages the whole DOM is full of <!--render facet: 5:0--> ...
2
votes
2answers
55 views

Can DOM matches logic be applied to an LWC LightingElement?

One problem stopping Mobiscroll calendar working inside a LWC? is described in the PS to that question. An equivalent of element.matches (AKA element.matchesSelector) needs to be implemented for an ...
0
votes
1answer
97 views

LWC third party library DOM changes not applied

I'm trying to use Highcharts charting library in LWC. I have an empty div element, <div class="chart-target" lwc:dom="manual"></div> targeted by the chart. This works well. The problem is ...
1
vote
1answer
1k views

Jest Test - element.shadowRoot.querySelector() not retrieving element when given an id

I am attempting to retrieve and make assertions about certain elements using querySelector() with the respective id of that element. But, querySelector() isn't returning any elements with a given id. ...
1
vote
1answer
822 views

Dynamically set the onclick function in LWC button

I'm trying to dynamically set the onclick function of lightning web component button but it's not working. I've tried both "click" and "onclick" JS: const navButton = this.template.querySelector('....
0
votes
1answer
34 views

How to remove dom response from a loop

I have a dom class handler which I am calling from batch class. I am looping through the response to perform dml operations across certain objects. Since I have to use the response across different ...
1
vote
0answers
62 views

Entire page appearing twice in the DOM in LEX?

So the two snippets in this screenshot are the same page loaded in Lightning. This is the "main div" as I can see it that holds the main contents of the page. I promise it is the same page, a standard ...
2
votes
1answer
100 views

The key attribute, and docs on LWC Virtual DOM

Per the LWC docs we have the following: When a list changes, the framework uses the key to rerender only the item that changed. The key in the template is used for performance optimization and ...
5
votes
2answers
713 views

Clarification on what this.template.querySelectorAll lets you see in LWCs: want to modify field labels

I have a form rendered using just a lightning-record-form - very cool to get so much done by this single LWC (Lightning Web Component). But I'm trying to replace the labels with the inline help text ...
3
votes
1answer
2k views

Export a CSV using lightning Component without DOM modification

Lightning Controller getData : function(component, file, fileContents) { var action = component.get("c.data"); action.setCallback(this, function(response) { var state = ...
2
votes
1answer
2k views

div innerHTML with standard lightning web components

I'm trying to display a custom format for my lightning web component via rendered and innerHTML of a div. <template> <div class="container" lwc:dom="manual"></div> </template&...
0
votes
0answers
113 views

System.SerializationException: Not Serializable: dom.Document for displaying hierarchial Documents

Code is very big hence mentioning only relevant stuff , When I click on 'DocumentCallAll' tab, from the class I am getting the value in string jsonStr1 and then it need to pass on page and display the ...
1
vote
1answer
284 views

Document.fullScreen API implementation in Lightning Web Components(LWC)

I was trying to achieve full screen on an element in Lightning Web Components but was unable to use Document.fullscreen API. I tried var elem = this.template.querySelector('svg'); if (elem....
1
vote
0answers
763 views

LWC: Using lwc:dom=“manual” to reach and interact with a certain DOM element

I am trying to find a way to interact with the built-in chat widget. I need to simulate a click on it. I understand that the Locker Service is there to prevent any interaction outside of the DOM of ...
0
votes
1answer
284 views

Dom Document generation by APEX code

I am writing APEX to generate DOM document. I want to generate <TOTALVOLUME units="m3">1.0</TOTALVOLUME>. Parent node for TOTALVOLUME is consignmentBody and I am trying Below code to ...
1
vote
0answers
224 views

I'm not able to access DOM element even in “afterRender”

I'm trying to create a canvas in my custom lightning component. This is a child component of another component. The canvas draws few charts, and the methods are called only after both the script(...
0
votes
1answer
185 views

Lightning data locker restricting Javascript for CSS/HTML

I am trying to retrieve JavaScript Static resource in Community lightning component to override the numbering from Unescaped html. But the data locker service is blocking the script. Am trying to ...
4
votes
0answers
575 views

Lightning Web Components: Set scroll position on lightning-datatable based on 'key' field value

We are looking to auto-scroll the user to a specific point in a lightning-datatablewhen a button is clicked. Assuming we referenced the key-field attribute data-row-key-value in the dom then in HTML ...
5
votes
1answer
11k views

Using this.template.querySelectorAll() to modify the DOM in Lightning Web Component

Currently, I am stuck in a situation to modify the DOM in LWC using the querySelectorAll function. Here the {team.item.Description__c} field having the DOM details and saved in string form into the ...
1
vote
1answer
265 views

How to build an integration with rest API in apex using XML

Situation I need to build a connection from Salesforce to "post" to a rest api. The recipient has given me XDS schema files of the data to be sent over. My Current Plan Build a sObject to be the ...
0
votes
2answers
1k views

Document.getElementById().value returning Null in Lightning

I am getting null value from Lightning component from document.getElementById().value below is the case. I am showing already existed record as default(pricebookId) in the dropDown from total list. &...
0
votes
1answer
2k views

Read document cookies in Lightning Component [duplicate]

I want to read the cookies out of the DOM document object. I tried the following: Controller: init : function(component, event, helper) { console.log(document.cookie); // returns nothing } ...
0
votes
1answer
199 views

ltng:require afterScriptsLoaded will run after dom was fully loaded. Why?

ltng:require afterScriptsLoaded will run after dom was fully loaded. Why? I mean where is it documented? I saw it, for example, here As per @TrevorBliss comments , adding afterScriptsLoaded to ...
1
vote
1answer
663 views

getBoundingClientRect() does not work in lightning component?

Every example I am seeing about positioning a tooltip manually involves getting client boundaries, which you would get through getBoundingClientRect() on the element. I have a lightning component ...
8
votes
2answers
3k views

How to add a <meta>-Tag for an Lightning app

Is possible to add a <meta> tag for my Lightning application? Within the Salesforce1 mobile application my iPhone turns a custom-formatted date visualization into a hyperlink to create a native ...
1
vote
0answers
246 views

How to programmatically identify that no modal is visible on screen?

I want to identify that screen does not have any modal visible, and based on this, I want to show or hide the window's default scrollbar. To show/hide the scrollbar I got excellent solution from this ...
1
vote
1answer
3k views

Onclick handler doesn't fire in dynamically-added dom element

The interface for my Lightning component is a very dynamic table that must be built according to data that is retrieved from a remote source. To create this table, inside of my helper class, I'm using ...
3
votes
1answer
4k views

DOM manipulation on lightning:datatable

I want to add attributes or classes for rows/cells in lightning:datatable based on cell values (I want to customise styles based on values). Is it possible? How can this be achieved? P.S. I tried to ...
1
vote
2answers
2k views

Retrieve elements created with Aura:Iteration

I'm trying to retrieve elements using document.getElementsByClassName("") within the afterRender function. This works as expected with normal elements. However, I can't seem to retrieve elements being ...
6
votes
2answers
1k views

AfterRender on button in Lightning Component (DOM update)

I am trying to do something that sounds easy in JavaScript but that I have difficulty to do with Lightning component. The functionality is to highlight the currently pressed button as explained in ...
2
votes
1answer
171 views

What is the benefit in using the $Component selector?

Reading through a topic - Best Practices for Accessing Component IDs, I learned that: Use the $Component global variable to simplify referencing the DOM ID that is generated for a Visualforce ...
0
votes
1answer
101 views

Injecting HTML into a specific location in email

I'm looking for a way to inject HTML into a specific location in an email. I'm thinking something like a javascript DOM. Essentially We have coupons that use a specific set of variables, lets use ...
0
votes
1answer
117 views

Is it possible to add apex:inputFile dynamically to the DOM during runtime with Javascript?

I can add html elements to the DOM but how do I add a VF element such as apex:inputFile? From this post I understand that I can use a wrapper class and apex:repeat but I was wondering if there is ...
2
votes
0answers
619 views

Lightning Components: what is the easiest way to get the components DOM root element without a wrapper in the markup?

I'm having a couple of very different components and often I need to do some work on the components root DOM-node. Some of the compos have Version<=39.0 other have 40.0+ and therefore I'm not ...
6
votes
1answer
376 views

event propagation breaks with API v40 - FundExplorer Demo app

Szenario We want to refactor a dynamic created list by using only one click event listener on the surrounding <ul>-tag rather having one on each <li>-tag as recommended by Christophe ...
2
votes
1answer
143 views

How do i empty the value in lightning without violating DOM Modification

Component <input onchange="{! c.readCSV}" accept=".csv" type="file" id="file-upload" aura:id="file-upload"/> Controller readCSV : function(component, event, helper){ var file = component....
2
votes
2answers
846 views

How to get all buttons in my page from a controller javascript function(component, event, helper)?

I know how to enable the clicked button. Lets say I want to enable all buttons on the click of a button. The button is in a Lightning component as: <aura:component implements="flexipage:...
2
votes
1answer
130 views

How to prevent DOM XSS Vulnerability for this script -

{!tableData} is Server variable. <script> $('.content').html("{!tableData}"); ... </script> "{!tableData}" is having HTML data.
0
votes
1answer
36 views

JavaScript reading visualforce binded variables

I need some help understand how JavaScript and Visualforce interact. I have a eventListener that works perfectly when the DOM is loaded: window.addEventListener('DOMContentLoaded', function() { if (...
0
votes
1answer
3k views

Root Element with two or more namespace in a XML Document

How can I add two or more namespace on root element in a XML Document? In Java, I create the XMLNode with two namespace and then I set it as root element in a XML Document. In Salesforce, I have ...
2
votes
1answer
581 views

getBodyDocument returns null

I'm trying to write tests using httpCalloutMock in a fashion similar to global class MyHttpMock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest httpRequest){ ...