Hot answers tagged

8

Those restrictions were never correctly stated and I have been working with the App Exchange review team and our technical writers to get this corrected. That "requirement" was only meant for DOM elements that the LC framework creates and manages on your behalf. It was never meant to include DOM subtrees you create yourself or via React, Angualr, etc. Trying ...


6

It's very nicely described in the documentation that you linked what it does and how it works. It's for simplicity to reference components throughout the hierarchy, without the need of explicitly providing an ID for every single component and writing ridiculous selectors. Have a look at the following examples to see the benefit: <apex:page id="page"> ...


5

I was able to get something to work by calling addEventlistener rather than setting an attribute. However, I wasn't able to add a regular Lightning controller function via component.getReference() - I'm going to investigate that further. However, for now, this should work as long as the sforce.console is defined (I would have thought it wouldn't be ...


5

The DOM (DOM (Document Object Model) is just a model of the document. It could be a HTML/XHTML documents or XML document. The DOM only describes a structure of objects and it representation and accessibility. Document Object Model HTML DOM XML DOM Javascript DOM In relation to Salesforce you have some ways where you can "use" DOM in Apex programming ...


4

In Lightning I would be much more inclined to create this list through an aura:iteration at the component markup level, bound to an array that you can set, rather than appending strings to innerHTML. However if you still want to do it this way... The innerHTML property is a string, not a reference. You are assigning it to a variable, building it up and then ...


4

'{!bvs.Status__c}' is guaranteed to never be null, because even if Status is an empty string, your code effectively evaluates as: if('' != null) { Clearly, "empty string" is not the same as null, so this condition is always true. Instead, consider using: if({!ISBLANK(bvs.Status__c)}) { Which will evaluate to this when the string is empty: if(true) { ...


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}"/> ...


4

I would not use afterRender to attach events, as you'll end up possibly adding duplicate events. Here's a simplified version that does not rely on a renderer: <aura:application > <div id="myDIV" onclick="{!c.setActive}"> <lightning:button class="btn" aura:id="bout" label="1"/> <lightning:button class="btn active" ...


3

This could depend on a lot of things. For example, if your <aura:iteration> is looping over data that you're retrieving via an Apex controller, then the first time it is rendered there will be no components because it hasn't got the data from the server yet. One of the later renderings will include the data. As a general rule, you would be better ...


3

Since you have an aura:id on your button(s), why not simply use the toggle utility method to remove/add the class you need to highlight the button being pressed "onclick"? Javascript in the context of the aura:framework and with locker service will require a change of habits when developing. since you have an aura:id set to "bout" for all your buttons, when ...


3

Modern browsers support Data URIs, meaning that you can do this: app <aura:application > <ui:button label="Download" press="{!c.download}" /> </aura:application> controller ({ download: function(component, event, helper) { var a = document.createElement("a"); a.href = "data:text/csv,base64;ImhlbGxvIiwid29ybGQiCg==...


3

you can get the response here Two Options 1.- If you are building a Community, You can Add it from All Communities -> Builder -> Settings -> Advanced -> Edit Head Markup 2.- If you are building a Standard Lightning APP, You can Add it from Javascript, but you dont need to use JQuery (I think is your problem). In a Lightning ...


3

I see that your XML string contains one single node, Order, and its content is a JSON string, not having children XML nodes, so you can't invoke getChildElement() with a non-existent subnode. Try to change xml variable content to: <Order> <pl.map_00NF0000008ZKQu_012F00000011jfx> {\'Lupron Ped Call Plan update\':\'fwAA\'}; </pl....


3

Using the Dom.Document interface, there's no way to append a node arbitrarily as a child to another node. You could write such a function, though, by accepting two nodes in a function, the target and the source, and recursively adding the source to the target: void addChild(Dom.XmlNode target, Dom.XmlNode source) { ... } This, as you might imagine, ...


3

As others have mentioned, the LockerService means you can't attack the problem via the DOM, but instead have to see what the component offers. I followed the lightning:datatable JavaScript through in the debugger and found that the cellAttributes mechanism documented to support this: { label:'Confidence', fieldName:'confidence', type:'percent'...


3

You're possibly overthinking it. Debugging from a FilteringProxyHandler will result in the illegal invocation error you're seeing, but simply accessing the parameters normally shouldn't cause an error: var rect = component.find("testDiv").getElement().getBoundingClientRect(); console.log(rect.top); console.log(rect.left); ...


3

Locker is currently preventing access to the fullscreen API, not LWC. You can try out the following snippet of javascript in the Locker console. document.body.requestFullscreen // Locker OFF: function requestFullscreen() {[native code]} // Locker ON: undefined


2

You can construct a SOAP request using those classes. Using the DOM classes is easier because using those you do not need to work at such a detailed level in your code. Here is an example of a SOAP message from the Examples of SOAP Messages section of the "Simple Object Access Protocol (SOAP) 1.1" spec: POST /StockQuote HTTP/1.1 Host: www.stockquoteserver....


2

The REST API version of the Tooling API is returning JSON by default where you are trying to read it into an XML document. You could either tell the REST API that you want XML in the response (Accept request header) or process the response as JSON. It's a bit raw, but here is a JSON version. HttpRequest req = new HttpRequest(); req.setHeader('...


2

Simple way use for attribute of apex:ouputlabel and pass the id <apex:outputLabel value="Checkbox" for="theCheckbox"/> <apex:inputCheckbox value="{!inputValue}" id="theCheckbox"/> Let me know if this solved your problem or not


2

The Apex DOM parser is the simplest to use. The code would look something like this: public static Advertiser__c[] parseXML(String xmlValue) { Dom.Document doc = new Dom.Document(); doc.load(xmlValue); Advertiser__c[] advertisers = new Advertiser__c[] {}; for (Dom.XmlNode child : doc.getRootElement().getChildElement('advertisers', null)....


2

Praveen,Peter The issue here is to be able to invoke the rerender() method of Renderer, when we want it to. We are able to achieve this by using following approach : We go to a helper method using 'afterScriptLoaded' In the helper method we fire a dummy event(which is not handled anywhere) after setting a boolean(firing an event always invokes re-render ...


2

You have to set the document yourself in order to use it in a mock callout: HttpRequest r = new HttpRequest(); Dom.Document body = new Dom.Document(); body.load('<?xml version="1.0" encoding="utf-8"?><root><child /></root>'); r.setHeader('Content-Type', 'application/xml'); r.setBodyDocument(body); HttpRequest does mention the Dom....


2

On item 1, not too clear what your problem is, but to call the code with a URL you would use: Strign url = 'https://...'; new DomDocument().parseResponseDom(url); (See the DOM.Document documentation for how to load the XML from a string that might have come from e.g. a static resource.) On item 2, if the XML doesn't contain namespaces (as yours doesn't) ...


2

It's mentioned in this documentation: The afterScriptsLoaded action in the client-side controller is called after the scripts are loaded and the component is rendered. Don't use the init event to access scripts loaded by <ltng:require>. These scripts load asynchronously and are most likely not available when the init event handler is called. As you ...


2

It's not clear to me why you need to do this imperatively. Would the following accomplish the same thing? <template if:true={teamRecords} > <template for:each={teamRecords} for:item="team" for:index="index"> <div key={team.item.id}> {team.item.Description__c} </div> </template> </template&...


1

Christian, thanks for the detailed information. This is not only helping us to understand the issue, but I'm sure the whole community will benefit from your remarks. What's going on? As I undestand it, the behavior you are witnessing is working by design. And it's not only because of LockerService. You see, in a component-based architecture, what's ...


1

You will need to encode using JSENCODE and HTMLENCODE . Here is what you can do <script type="text/javascript"> $('.content').html("{!JSINHTMLENCODE(tableData)}"); ... </script>


1

you can get all the ui:button's in the component, since they exist in the 'v.body' of the components super (every component has a super, if none defined it's merely aura:component): var buttons = component.getSuper().find({ instancesOf : "ui:button" }); if (buttons) { for (var i=0; i < buttons.length; i++) { buttons[i].set("v.disabled", false)...


1

You can set as many namespaces as you'd like with setNamespace. Here's a trivial execute anonymous script: Dom.Document doc = new Dom.Document(); Dom.XmlNode root = doc.createRootElement('root','http://defaultns/',''); root.setNamespace('a','http://example-ns1/'); root.setNamespace('b','http://example-ns2/'); System.debug(doc.toXmlString()); Output (note: ...


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