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

amd, require.js javascript example please #26

Open
jeacott opened this issue Jan 13, 2013 · 4 comments
Open

amd, require.js javascript example please #26

jeacott opened this issue Jan 13, 2013 · 4 comments
Milestone

Comments

@jeacott
Copy link

jeacott commented Jan 13, 2013

Hi, I'd love an example or wiki entry that explains how to use this component with requirejs, or to have an amd compatible version out of the box. is it possible?

@alekseykulikov
Copy link
Owner

Hi, it is not for now. Added as feature for next release.

@maxfi
Copy link
Contributor

maxfi commented Feb 14, 2013

@jeacott You can shim backbone.offline when using require.js. You should set out your require.config as below:

require.config({

    baseUrl: 'scripts',

    paths:{
        'jquery': 'vendor/jquery/jquery',
        'underscore': 'vendor/underscore/underscore', // amd fork
        'backbone': 'vendor/backbone/backbone', // amd fork
        'backbone.offline': 'vendor/backbone/backbone.offline'
    },

    shim:{
        // This is the important line for you. It tells require.js that backbone.offline depends on backbone. 
        'backbone.offline': ['backbone']
    }

});

You'll likely also want to use the AMD forks of backbone and underscore which can be found at https://github.com/amdjs

@alekseykulikov
Copy link
Owner

HI @maxfi, thank you for great introduction to require.js. I think shim part should looks so, but I'm not sure about exports:

shim: {
  'backbone.offline': ['backbone', 'underscore', 'jquery']
  exports: 'Offline'
}

I will test it and then add to docs for next release.

@maxfi
Copy link
Contributor

maxfi commented Feb 17, 2013

Hi @ask11. I don't use the exports command and it seems to work. I'll look into it.
I'd be happy to help out with the documentation for the wiki if you like? Where is the best place to discuss this further?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants