Hot answers tagged

30 votes

Using unescape HTML in lightning web component

You can use: <lightning-formatted-rich-text value={team.item.siteComponent.Description__c}></lightning-formatted-rich-text>
user avatar
21 votes
Accepted

Lightning: How to change page title for lightning app?

Today you can add this: document.title = "Your Title"; in your .app's init handler: <aura:handler value="{!this}" name="init" action="{!c.init}"/> in your app's controller: init: function(...
user avatar
  • 9,984
17 votes

Using unescape HTML in lightning web component

You should be able to inject the raw HTML via Element.innerHTML. You will also need to make sure to add the lwc:dom="manual" directive on the container element to indicate to LWC that you are tacking ...
user avatar
  • 2,307
14 votes
Accepted

The purpose of ARIA attributes in Lightning components

The Accessible Rich Internet Applications specification provides accessibility features for disabled individuals, as stated in the RFC: Accessibility of web content requires semantic information ...
user avatar
  • 438k
11 votes
Accepted

How can I render text as HTML on a page?

To output pre-formatted HTML, use aura:unescapedHTML. You can pass in values from a controller, such as: <aura:unescapedHtml value="{!v.note.body}"/>
user avatar
11 votes

How to repeat HTML table header (thead) for each page rendersAs pdf

Inside your CSS in tables style tag, you need to add the following attribute: table { -fs-table-paginate: paginate; } puts a header at the start of each new page where a table crosses a page ...
user avatar
  • 40.4k
11 votes
Accepted

CSS file upload and store in Marketing Cloud

Within your Cloud Page collection, you can create a Code Resource: After you fill out the name of the code resource, you can select the type, which in your case will be CSS: You will now be able to ...
user avatar
  • 17.1k
10 votes

How to use custom html pass through attributes in Lightning Components?

data- custom attributes are only supported by HTML components in Lightning. The same is true for VF - the apex:outputText component was written to specifically support custom HTML attribute pass ...
user avatar
  • 9,984
10 votes

Cannot get attribute value from <a> tag when <img> is an element of it

Due to event bubbling, when you click on the img tag anchor tag's onclick event is being fired. As a result, event.target => points to the element where the click originated which is the <img/>....
user avatar
  • 10.1k
10 votes
Accepted

Id attribute of an element gets changed in LWC

You cannot stop that, also it's not recommended to manipulate DOM elements based on id, as the framework replaces custom id to globally unique id in the page. So to get element you have two options. ...
user avatar
  • 10.8k
9 votes
Accepted

Why use <ui:inputText> instead of <input type="text">?

The advantage is styling and general ease of use. According to the documentation, you can use this code: <ui:inputText label="Expense Name" value="My Expense" required="true"/> To generate all ...
user avatar
  • 438k
9 votes
Accepted

Lightning Components: What is the easiest way to have an onclick event on a HTML-tag?

Inline Javascript is not supported due to security threat and you can simply use onclick event and always follow the Unobtrusive principles.You can look at document here which mentions to avoid inline ...
user avatar
9 votes
Accepted

Add spinner text along with spinner in lightning component

There is a spinner component already in lightning. You can use this then with a little css add your text in the style. Component <aura:if isTrue="{!v.spinner}"> <lightning:spinner class=...
user avatar
9 votes
Accepted

Changing colors of lightning-button

Based on my understanding of the documentation, your CSS cannot reach into the child component of the lightning-button component: Styles defined in a component’s style sheet are scoped to the ...
user avatar
  • 19.4k
9 votes

Issue with for:each Index in LWC

LWC does not support expression evaluation in the markup yet. I have raised an idea for it a few months back. You have alter your JS to support complex javascript object with index of your choice. ...
user avatar
9 votes
Accepted

LWC: Only enable button if options are available

You need to use the property with the get method. JS get disableButton(){ return !(this.options && this.options.data && this.options.data.length); } HTML <lightning-button ...
user avatar
  • 10.8k
8 votes
Accepted

Use Similar to Apex:Repeat in non-visualforce HTML email template

No. HTML templates only support standard formulas, and of those, only those that make sense in context. It doesn't have support for advanced scripting like loops, variables, and other stuff you have ...
user avatar
  • 438k
8 votes
Accepted

How can I force Visualforce to include empty attributes which I have specified?

Here is another way to do it w/o javascript: Set the value to a VisualForce function that evaluates to nothing: <apex:page standardController="Contact" > <apex:form> <select ...
user avatar
7 votes
Accepted

Apex/Visualforce: multiline IF statement in HTML

Use like below <apex:outputtext value="!IF(ISNULL(Eslot.sEvent), 'Free', IF(Eslot.sEvent.Appointment_Type__c == 'Personal', 'Pers', 'Fill'))}"/> else <apex:outputPanel rendered = "{! If(m....
user avatar
  • 22.1k
7 votes

Apex/Visualforce: multiline IF statement in HTML

Visualforce has IF() function <strong> <apex:outputtext value="{!IF(condition, 'This HTML.', 'This is the false HTML.')}"/> </strong> In apex we have if and else statments .You ...
user avatar
7 votes
Accepted

Populate a SLDS picklist dynamically with SelectOptions

If you want the select option to look like SLDS picklist then just use the css class on SelectOption component. Like this: <div class="slds-form-element"> <label class="slds-form-...
user avatar
7 votes

Issue with for:each Index in LWC

Its not Var. Its var (case sensitive). This is not possible because using LWC iterators you will be able to get item, index, firstItem, and lastItem. You can use either for:each or iterator:...
user avatar
7 votes
Accepted

LWC not formatting the string in HTML tags

Looks like the string from apex is html markup, more likely from Rich Text Area. You can use lightning-formatted-rich-text to maintain formatting. <div> <lightning-formatted-rich-text value=...
user avatar
6 votes
Accepted

UI for custom merge

The Salesforce Foundation's Nonprofit Starter Pack has a custom merge functionality with a "paint your own record" type UI. The code is open source. Here is a good overview of the functionality: http:...
user avatar
  • 14.5k
6 votes
Accepted

Escape = False On OutputText Not Rendering HTML In RichText

Per doc: https://help.salesforce.com/HTViewHelpDoc?id=fields_using_rich_text_area.htm&language=en_US HTML code is not supported in the Salesforce HTML editor. HTML code is treated as text. ...
user avatar
  • 7,346
6 votes
Accepted

Salesforce reformatting HTML in visualforce page when rendering SVG

Definitely seems like a bug with the processing engine to me. If you wrap everything inside the <h1> tags with no-layout output panel then the generated HTML comes out as expected: <apex:...
user avatar
  • 24.7k
6 votes
Accepted

<tr> and <td> tags within <apex:repeat> rendering above the table?

You need to use outputText instead of outputPanel. outputPanel is intended to be used as reRender targets, and to group content together. The documentation for outputPanel states: A set of content ...
user avatar
  • 438k
6 votes
Accepted

Hide HTML table rows if outputField is null or 0

You can use display:none; in a style attribute to hide elements. <table style="{!IF(relatedTo.Item1__c == null, 'display: none;', '')}"> Don't forget, if you want to also check for 0 values, ...
user avatar
  • 143k
6 votes
Accepted

Lightning Component - Get html button id in controller.js working in firefox, not in chrome

In your JS Controller, you should use event.currentTarget.id instead of event.target.id. This is because when you click on your svg (the target), your click event isn't handled as there is no onclick ...
user avatar
6 votes
Accepted

Remove vertical ScrollBar from Lightning Page

In addition to my comments above if you really need to do this it can be added to the init handler as such: document.body.setAttribute('style', 'overflow: hidden;'); Which I have used many times to ...
user avatar
  • 53.2k

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