I'm trying to load JQuery and JQuery UI in a Lightning Component. JQuery is loading fine, but JQuery UI is giving me an error

"Uncaught TypeError: n[o].hasOwnProperty is not a function"

I loaded the same files in a visualforce page and it worked, so i don't know why it's not working in a lightning component.

My Code:

<aura:component >
    <ltng:require styles="{!$Resource.style + '/jquery-ui.min.css'}" />
    <ltng:require styles="{!$Resource.style + '/jquery-ui.structure.min.css'}" />
    <ltng:require styles="{!$Resource.style + '/jquery-ui.theme.min.css'}" />
    <ltng:require styles="{!$Resource.style + '/normalize.css'}" />    

    <ltng:require scripts="{!join(',',$Resource.jquerylib + '/jquery-3.1.0.min.js', $Resource.jquerylib + '/jquery-ui.min.js')}" afterScriptsLoaded="{!c.scriptsLoaded}"/>

    <a id="test" href="#">Test JQuery</a>
  • 1
    can you try using jquery version 2, not sure if jquery v3 is fully compatible with locker service. – Praveen Sep 29 '16 at 17:04
  • Well but JQuery it's working, the problem is with JQuery UI... – Ricardo Coutinho Sep 30 '16 at 8:31
  • 1
    Ok i tried JQuery2 and it worked, but the problem is that my script now is full of errors, i have to change everything. I love how Lightning Components work, but this problems with external libs is slowly killing my interesse on them. – Ricardo Coutinho Sep 30 '16 at 8:55
  • What errors do you see? Is it related to jquery-ui.js? if thats' the case then you might need to raise a case with sf support – Praveen Sep 30 '16 at 9:30
  • Well i had a script with a lot of jqueryUI functions and in visualforce it worked well with latest JQuery and latest JQuery UI. But now, in lightning i have to use Jquery2 so there are many functions not working, and i guess it's pretty normal because that functions probably are from Jquery3. – Ricardo Coutinho Sep 30 '16 at 9:33

Try using jquery v2, i don't think jquery v3 is fully compatible with locker service.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.