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

Uncaught TypeError #99

Open
extractachris opened this issue Oct 9, 2015 · 1 comment
Open

Uncaught TypeError #99

extractachris opened this issue Oct 9, 2015 · 1 comment

Comments

@extractachris
Copy link

I have this function:

initSubViews: function() {
  var that = this;
  $('[data-controller]').each(function() {
    var controller = $(this).data('controller');
    var viewPath = 'views/' + controller;
    var el = $(this);
    require([viewPath], function(View) {
      var view = new View({
        el: el,
        eventBus: that.eventBus
      });
    });
  });
}

Which gets converted into this when I run amdclean:

initSubViews: function() {
  var that = this;
  $('[data-controller]').each(function() {
    var controller = $(this).data('controller');
    var viewPath = 'views/' + controller;
    var el = $(this);
    (function(View) {
      var view = new View({
        el: el,
        eventBus: that.eventBus
      });
    }());
  });
}

When I run my app, console reports: Uncaught TypeError: View is not a function and traces it to this line:

var view = new View({

Any ideas what it would be tripping up on?

@sprat
Copy link

sprat commented Dec 7, 2015

I guess that's because the require'd module name is dynamic, which is not handled by amdclean I think.

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

2 participants