metafizzy / outlayer

:construction_worker: the brains & guts of a layout library
163 stars 63 forks source link

RequireJS & jQuery breaks #1

Closed desandro closed 11 years ago

desandro commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

whoops, closing here.