cowboy / jquery-hashchange

This jQuery plugin enables very basic bookmarkable #hash history via a cross-browser HTML5 window.onhashchange event.
http://benalman.com/projects/jquery-hashchange-plugin/
GNU General Public License v2.0
1.21k stars 258 forks source link

Using Requirejs #32

Closed peduarte closed 11 years ago

peduarte commented 11 years ago

Has anyone used this with Requirejs? I am struggling to get it to work.

This is what I have at the moment:

var require = {
    enforceDefine: true,
    paths: {
        'jquery': '/js/vendor/jquery.min',
        'hashchange': '/js/vendor/jquery.hashchange.plugin',
    },
    shim: {
        'jquery': {
            exports: '$'
        }
        'hashchange': {
            deps: ['jquery'],
            exports: 'Hashchange'
        }
    }
};

And this is how I define it later on:

define(['jquery', 'hashchange'], function ($, Hashchange) {
    // code
});

Any tips will be very appreciated, Thanks!

peduarte commented 11 years ago

Got it to work... problem was with the exports option in the shim: {};

'hashchange': {
    deps: ['jquery'],
    exports: 'jQuery.fn.hashchange.'
}