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

Using with require.JS #272

Open
youradds opened this issue Mar 6, 2018 · 0 comments
Open

Using with require.JS #272

youradds opened this issue Mar 6, 2018 · 0 comments

Comments

@youradds
Copy link

youradds commented Mar 6, 2018

Hi,

I'm trying to get this going with require.js. I have the following:

// Configure loading modules from the lib directory,
// except 'app' ones,
requirejs.config({
    "baseUrl": "js/lib",
    "paths": {
      "common-functions": "common-functions",
      "domReady": "domready",
      "storage": "storage",
    },
    "shim": {
        "common-functions": {
            //"deps": ["jquery","datepicker","domReady"]
            "deps": ["storage","domReady"]
        }
    }

});

require(['storage'], function(store) {
    require(['domReady','common-functions'], function(domReady){
      store.set("foo","bar"); // this works ok!
    }, function (err) {
      console.log("Error: " + err)
    });
});

It works like this as "store" is available - however, if I were to use it in the test common-functions.js, I get an undefined value for store:

common-functions.js =>

store.set("foo","bar");

ReferenceError: store is not defined

Do I need to wrap common-functions.js with something to make it work?

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

1 participant