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

RequireJS & jQuery breaks #1

Closed
desandro opened this issue Aug 6, 2013 · 2 comments
Closed

RequireJS & jQuery breaks #1

desandro opened this issue Aug 6, 2013 · 2 comments

Comments

@desandro
Copy link
Member

desandro commented Aug 6, 2013

From metafizzy/packery#20

It works brilliantly for me, until I attempt to use it with jQuery, which is where i get the classic "Object [object Object] has no method 'packery' " error (I'm following the config paths option from the appendix link you posted). I tried to shim it in the config with a dep of jquery, but to no avail. Do you know what I'm missing?

@desandro
Copy link
Member Author

desandro commented Aug 6, 2013

Here's my solution:

requirejs.config({
  // change base_path to bower_components
  baseUrl: '../bower_components/',
  // add path config for jQuery
  // see http://requirejs.org/docs/jquery.html#modulename
  paths: {
    jquery: 'jquery/jquery'
  }
});

// require jQuery bridget, which will enable $.fn.packery
requirejs( [ 'jquery-bridget/jquery.bridget', 'packery/packery' ], function() {
  var $ = window.jQuery
  $('#basic').packery();
});

I'll add this to the documentation shortly.

@desandro
Copy link
Member Author

desandro commented Aug 6, 2013

whoops, closing here.

@desandro desandro closed this as completed Aug 6, 2013
desandro pushed a commit that referenced this issue Oct 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant