1

I have a couple of applications built in Salesforce's Lightning Components.

Recently Salesforce released their Summer '16 Major Release this past weekend, on June 4th 2016. Something weird happened and now I'm getting a weird error every time I try to load any of my applications.

NOTE: I can load other JS libraries, such as svg4everybody just fine, jQuery is the only one I've tried that fails, and my applications heavily depend on it.

Error

Uncaught TypeError: Cannot read property 'expando' of undefined
throws at /resource/jquery:5:8159

That's when I have the following code in a new Lightning Application that I created to see what is up with this jQuery load error. Here's the code I have in the new app:

<aura:application>
  <ltng:require scripts="{!$Resource.jquery}" afterScriptsLoaded="{!c.init}"/>
  <div>
    <button aura:id="buttonThingy" onclick="{!c.clickMe}">Click Me!</button>
  </div>
</aura:application>

In the init function I've got this:

init: function(component, event, helper) {
    console.log('running init');
},

Simple yes?

If I check Chrome's Console Log with the Log XMLHttpRequests checked in console settings, I can see that the request to load jQuery was a success since it says so...

app.js:713
XHR finished loading: GET "https://myOrgDomainName.lightning.force.com/resource/jquery".

Did anyone have this problem yet? If so how did you resolve it?

I've tried uploading minified, unminified, zipped up versions of jQuery to the Static Resources in my Org, and still no luck. Also switched between it being a Private and Public static resource. Still no luck.

5 Answers 5

4

What version of jQuery are you using? The thing that changed in Summer'16 is the introduction of LockerService (lots of traffic in this forum during prerelease, webinars, release notes, etc). I've seen this issue and believe it had been corrected but some older versions of jQuery may still have issues with LS compatability.

The latest versions (1.12.4 and 2.2.4) of jQuery should be compatible with Locker Service - please let us known ASAP if updating to the latest branch you are using corrects the issue.

2
  • 1
    Thanks @doug, I've loaded in 2.2.4 version of jQuery, and the applications seem to load in. Still confused as to why if I updated to version 1.12.x from 1.11.x jQuery starts to throw that error. I read about the LockerService, and it seems that it is automatically activated, guess that's good. The problem with loading version 2.2.4 is that I use HighCharts / HighStocks to render some graphs of data, and now that plugin fails and gives me weird errors. So solved one problem and trying to solve another one. In all, 2.2.4 seems to be compatible with LS but the 1.12.4 isn't...
    – Prince
    Commented Jun 7, 2016 at 19:11
  • Hi Doug, i'm using 1.12.4 in a component i'm tinkering with (trying to get Christophe's carousel component running with locker on) and it's throwing this error - Uncaught TypeError: Cannot read property 'expando' of undefined throws at /resource/1483131774000/jquery1_12_4/jquery-1.12.4.min.js:5:8159" Commented Jan 21, 2017 at 21:24
3

After summer 16 release, we need to change the code to include the external JQuery/Css files from static resource. Here is an example of the same:

<ltng:require .... scripts="{!$Resource.JQuery}" />

Here JQuery is the static resource name, and this static resource is having only single JS File.

For a zip file having multiple files/folder follow another syntax:

<ltng:require ....  scripts="{!join(',', 
    $Resource.jsLibraries + '/jsLibOne.js', 
    $Resource.jsLibraries + '/jsLibTwo.js')}" />

More details you can find in following salesforce doc: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_libs_platform.htm

1

jquery 2.2.4 will work, but still you have do some tweaks to your code, the way you access DOM.

See how Locker Service works: https://developer.salesforce.com/blogs/developer-relations/2016/04/introducing-lockerservice-lightning-components.html

If you need you code be running up then go to setup > critical updates and deactivate locker services.

1
  • @Prince : is your problem solved ?
    – userdks
    Commented Jun 15, 2016 at 8:56
0

It's worked with 2.2.4 but it's did not worked with 1.12.4

enter image description here

2
  • That's weird...maybe it's something to do with Salesforce dropping support for Internet Explorer 10 and below. Let me try that and I'll add another comment on that!
    – Prince
    Commented Jun 7, 2016 at 15:52
  • Thanks @thoriyas for this. I updated to 2.2.4 and the applications seem to load fine. Having issues with other plugins which seem to only work with 1.11.x or 1.12.x version of jQuery :(
    – Prince
    Commented Jun 7, 2016 at 19:12
0

@Doug Can we expect this issue to be resolved by winter'17 release, as the LockerService will be auto-enabled for all orgs when Winter ‘17 is out. Replacing the existing Jquery with 2.* Jquery version impacts our current implementation, we can do away with this for time being by simply not enabling LockerService but once the Winter'17 is out this option won't be there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .