Salesforce Lightning Ready Toggle
Nowadays most of the salesforce projects are shifted to Lightning Ready and jQuery acts as a very good tool while designing Lightning Ready Pages. In this blog, we are going to learn how to create Lightning Ready Toggle.
_________________________
Requirements:
# <!--jQuery CDN-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
# <!--Salesforce Lightning Design System Static Resource-->
Download the Design System Zip.
<apex:stylesheet value="{!URLFOR($Resource.manpreet2050, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" />
Upload the zip file named manpreet2050 as your Static Resource.
# <apex:slds />
#Â <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">Â for SVG's Support.
#Â Set the StandardStylesheets to false and doctype to html-5.0Â
_________________________________________________________________________________
_________________________
Reference Code :Â
<apex:page docType=âhtml-5.0âł standardStylesheets=âfalseâ>
<!âjQuery CDNâ>
<script src=âhttps://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.jsâ></script>
<!âSalesforce Lightning Design System Static Resourceâ>
<apex:stylesheet value=â{!URLFOR($Resource.SLDS0102, âassets/styles/salesforce-lightning-design-system-vf.min.cssâ)}â />
<script> var j$ = jQuery.noConflict(); </script>
<html xmlns=âhttp://www.w3.org/2000/svgâ xmlns:xlink=âhttp://www.w3.org/1999/xlinkâ>
<head>
<meta name=âviewportâ content=âwidth=device-width, initial-scale=1.0âł/> <apex:slds />
</head>
<!âWrapping Divâ>
<div class=âmanpreetSingh2050âł>
<div class=âslds-form-elementâ>
<label class=âslds-checkboxâtoggle slds-gridâ>
<span class=âslds-form-element__label slds-m-bottomânoneâ>Field Name :</span>
<input id=âtogglexâ name=âcheckboxâ type=âcheckboxâ aria-describedby=âtoggle-descâ />
<span id=âtoggle-descâ class=âslds-checkboxâfaux_containerâ aria-live=âassertiveâ>
<span class=âslds-checkboxâfauxâ></span>
</span>
</label>
</div>
<!âSLDS Toggle Valueâ>
<div class=âslds-text-bodyâregular slds-m-topâsmallâ>
<span style=âfont-weight:bold;â id=âtoggleValue1âł>Disabled</span>
</div>
<script>
j$(â#togglexâ).on(âchangeâ,function() {
if(j$(this).prop(âcheckedâ)){
j$(â#toggleValue1â).text(âEnabledâ);
} else {
j$(â#toggleValue1â).text(âDisabledâ);
}
});
</script>
</div>
</html>
</apex:page>
_________________________
âYOU WANT ME TO PUT MY HAMMER DOWN! LIGHTNING IS MY NEW POWER".Â



