Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jquery problems #80

Open
oranze opened this issue Sep 14, 2018 · 7 comments
Open

Jquery problems #80

oranze opened this issue Sep 14, 2018 · 7 comments

Comments

@oranze
Copy link

oranze commented Sep 14, 2018

When loading Jquery and like example Jquery Cookie plugin via loader scripts not working. $ is undefined ... I think something with name spaces

@amorey
Copy link
Member

amorey commented Sep 14, 2018

By default LoadJS loads files with async=true which will cause problems if the plugin the loads before jquery. To avoid this you can use async=false:

loadjs(['/path/to/jquery.js', '/path/to/plugin.js'], {async: false});

@oranze
Copy link
Author

oranze commented Sep 14, 2018

I'm already solv this problem, but $.cookie just wont work... interesting what with delay 100ms it starting...

@amorey
Copy link
Member

amorey commented Sep 14, 2018

Can you share some example code? It doesn't sound like the problem is with LoadJS but if it is I can help you debug it.

Have you tried wrapping your jQuery code in $.ready()?

@oranze
Copy link
Author

oranze commented Sep 14, 2018

I have custom js framework for SAP application. This is hybrid of MVC and M -VC. Part of js code in Views.
Logic is next I load index.html which must load all css and JS libraries, after that in sync mode I load framework.js and global app.js (global functions and etc), and after all this loading I load custom app.js which overload some methods, functions, variables for this domain with it own settings, templates and etc. Next step start custom_app.js and it load via JQuery template plugin the Views. One of view check $.cookie('key')... and on that moment $.cookie is undefined... so this is some Jquery Cookie plugin bug. But also in that model I can't use your plugin to load JQuery... if I start some JQuery code in templates it show $ is undefined bug... So now I just load Jquery lib via <script src... all others files loading fine

@amorey
Copy link
Member

amorey commented Sep 14, 2018

Have you tried using async: false?

@oranze
Copy link
Author

oranze commented Sep 14, 2018

Yes... like I sad help delay timeout between run $.cookie in template. may be this is $.cookie plugin bug, but may be this is Gecko engine bug... I get same bug in any Gecko browser. IE not tested yet

@amorey
Copy link
Member

amorey commented Sep 14, 2018

Here's a fiddle that loads jQuery and jQuery-cookie using LoadJS without a delay:
https://jsfiddle.net/muicss/bd4L9omr/

Let me know if you're able to figure out the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants