520
Views
4
Comments
JQuery in reactive app, getting $ is not defined error.

I am writing a code to hide/show the content on window scroll, Have added the javascript code under javascript widget on OnInitialize page.


$(document).ready(function(){    
$('.xyz').hide();        
$(window).scroll(function() {            
if ($(window).scrollTop() > 350) {            
$('.xyz ').show();        
}        
else {            
$('.xyz ).hide();        
}
});
});

error.PNG
2023-10-21 19-42-11
Tousif Khan
Champion

Hello 

have you added a dependencies of Jquery

If Not then you can take the dependencies from here and add it into a required script of a page or a block as per your requirenment


But Since it is deprecated try to achive your code with JavaScript only without library.

Hope this works

Thanks

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

You should not use jQuery on reactive. OutSystems loads already way to much scripts, loafing jQuery is not good for performance.

What needs to be done is easily doable with jQuery.

2023-10-21 19-42-11
Tousif Khan
Champion

Yes thats why I told him try to achive this with JavaScript

2023-02-13 15-34-45
BabyBear

Using Jquery on reactive web app is not a good practice. I would suggest to translate your jquery script into a vanilla javascript code. But if you really need to use Jquery you can check this documentation


https://success.outsystems.com/Documentation/How-to_Guides/Integrations/How_to_include_a_jQuery_plugin

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.