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

How to import jQuery into global namespace (for Semantic UI) #327

Closed
tomitrescak opened this issue Jul 22, 2016 · 3 comments
Closed

How to import jQuery into global namespace (for Semantic UI) #327

tomitrescak opened this issue Jul 22, 2016 · 3 comments

Comments

@tomitrescak
Copy link
Contributor

Hi. I'm trying to use Semantic UI and I'm fading all css from it. The problem is that Semantic UI expects jQuery in the global namespace. I tried following to import it, but I still get 'jQuery' is not defined.

//file: config.js

import jquery from 'jquery';

global.$ = jquery;
global.jQuery = jquery;

import './semanticui'

Any idea how can this be achieved ?

@tomitrescak
Copy link
Contributor Author

Ok, this seemed to do a trick, when I put this code into my main .stories/index file.

import jquery from 'jquery';
global.$ = jquery;
global.jQuery = jquery;
require('./semanticui');

@purplecones
Copy link

Thanks for this @tomitrescak

I decided to npm install semantic-ui-css --save-dev package and import the files directly from it like so

// config.js
import jquery from 'jquery';
global.$ = jquery;
global.jQuery =  jquery;
require('semantic-ui-css/semantic.css');
require('semantic-ui-css/semantic.js');

@darekkay
Copy link

darekkay commented Feb 7, 2020

I've had issues integrating jQueryUI, so here's how I did it. It uses the jquery-ui module.

// config.js
import jquery from "jquery";
import jQueryAutocomplete from "jquery-ui/ui/widgets/autocomplete";
import jQueryDatepicker from "jquery-ui/ui/widgets/datepicker";

jquery.autocomplete = jQueryAutocomplete;
jquery.datepicker = jQueryDatepicker;
global.$ = jquery;
global.jQuery =  jquery;

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

3 participants