You need to sign in to do that
Don't have an account?
How to use jQuery plugin (datatable) in lightning component ?
Hi All,
Please look into this, I am not able to call the jQuery datatable function. Below are the details -
DatatableApp.app -
DatatableComponent.cmp -

I am using jquery data table (https://datatables.net/) here.
Need urgent help.
Thank you in advance.
Please look into this, I am not able to call the jQuery datatable function. Below are the details -
DatatableApp.app -
<aura:application > <c:DatatableComponent /> </aura:application>
DatatableComponent.cmp -
<aura:component controller="DatatableController"> <!-- Static Resource details - jQuery js file --> (jQUerySource), jQuery Datatable file --> (jqueryDatatableJS) --> <ltng:require scripts="/resource/1466061468000/jQuerySource,/resource/1466061531000/jqueryDatatableJS" afterScriptsLoaded="{!c.jsLoaded}"/> <!-- doInit method will call JS controller and then will get the details from Apex Controller and put in into the HTML using aura:iteration --> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <table class="display" id="#sampleTable"> <thead> <tr> <th>ID</th> </tr> </thead> <tbody> <aura:iteration items="{!v.cases}" var="case"> <tr><td>1</td><td>{!case.Id}</td></tr> </aura:iteration> </tbody> </table> </div> <div class="col-md-2"></div> </div> </aura:component>DatatableComponentController.js -
({ jsLoaded: function(component, event, helper) { debugger; $('#sampleTable').DataTable(); }, doInit: function(component, event, helper) { helper.getCaseList(component); } })DatatableComponentHelper.js -
({ getCaseList: function(component) { var action = component.get("c.getCases"); var self = this; action.setCallback(this, function(actionResult) { component.set("v.cases", actionResult.getReturnValue()); }); $A.enqueueAction(action); } })DatatableController.apxc -
public class DatatableController { @AuraEnabled public static List<Case> getCases() { system.debug([SELECT Id FROM Case limit 10]); return [SELECT Id FROM Case limit 10]; } }On click of preview button. I am getting this error -
I am using jquery data table (https://datatables.net/) here.
Need urgent help.
Thank you in advance.
Go to Setup select Critical Update
Deactivate: Enable Lightning LockerService Security
and paste below code in developer console
1 Step: Insert into component
<ltng:require scripts="/resource/Jq" afterScriptsLoaded="{!c.afterScriptsLoaded}" />
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 Step: Insert into Component
<button id="button1" onclick="{!c.dropdown}" class="slds-button slds-button--neutral">Show/Hide Columns
<img src="/resource/dropdownIcon" style="height:20px; width:20px;"/></button>
<p id="dropdown1">hi</p>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Step 3: insert into Controller
({
afterScriptsLoaded : function(component, event, helper) {
},
dropdown:function(component, event, helper)
{
// console.log("1st time");
// $.noConflict();
jQuery("#dropdown1").toggle();
//console.log("2nd time");
}
})
- for some orgs you can't disable the Lightning LockerService (if it is a Summer 2016 org that didn't have any Lightning components before)
- all orgs will have it enabled sometime around October 2016
If people have problems with their code running with the Lightning LockerService enabled, they need to work out how to fix the root cause soon. Something I'm finding to my cost at the moment, it breaks a lot of code.https://developer.salesforce.com/blogs/developer-relations/2016/04/introducing-lockerservice-lightning-components.html
Thanks!
What is the compaitble JQuery, Bootstrap version for lightning when we enable locker service
Hope this helps!
Thanks.
Share the link once you post the question.
https://developer.salesforce.com/forums/ForumsMain?id=9060G000000BiJYQA0
Thanks,
Dines