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

problem on the first example #57

Open
ofirk12 opened this issue Oct 17, 2016 · 7 comments
Open

problem on the first example #57

ofirk12 opened this issue Oct 17, 2016 · 7 comments

Comments

@ofirk12
Copy link

ofirk12 commented Oct 17, 2016

i get this meesage :
/react-bootstrap-multiselect/lib/bootstrap-dropdown.js:2
[2] if (typeof jQuery.fn.dropdown !== "undefined") return jQuery;
when i write var Multiselect = require('react-bootstrap-multiselect');
what can be the problem?

@HellMagic
Copy link

i discover the problem also

@skratchdot
Copy link
Owner

Are you including jQuery in your app, or is it being injected by 'react-bootstrap-multiselect'? I've changed the code recently due to people wanting to inject their own version of jQuery, so there might be a bug with that part.

Do you have a repo I can check out (or an online example)?

@aaronkw
Copy link

aaronkw commented Nov 2, 2016

I'm also running into that error. I'm not including jQuery explicitly in my app.

@skratchdot
Copy link
Owner

@aaronkw - what's the actual error message you see in the console? I don't really understand the original bug report without links to code. What bundler are you using (browserify/webpack/rollup)?

@redkyo017
Copy link

I've got the same issue , the bundler is webpack

@aaronkw
Copy link

aaronkw commented Aug 29, 2017

The issue for me is that previously (pre 2.2.0) the require('./boostrap-dropdown.js') was inside the if block that checks that there's a working window. With the new version, it breaks server-side rendering because bootstrap-dropdown.js gets loaded whether or not there's a window, and thus jQuery.fn is undefined.

2.1.0:

if (typeof window !== 'undefined' && typeof document !== 'undefined') {
  //Necessary for Universal Javascript apps
  //since JQuery requires a working window
  var $ = require('./bootstrap-multiselect.js').init(
    require('./bootstrap-dropdown.js').init(
      require('jquery')
    )
  );
}

2.2.0

var bsMultiselect = require('./bootstrap-multiselect.js');
var bsDropdown = require('./bootstrap-dropdown.js');
// setup jQuery
var $;
if (typeof window !== 'undefined' && window && window.jQuery) {
  $ = window.jQuery;
} else {
  $ = require('jquery');
}

@sman591
Copy link
Contributor

sman591 commented Aug 29, 2017

Related: #73 and #77

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

6 participants