7

I'm trying to import the jQuery plugin jQuery.scrollTo with JSPM.

So far I installed it with

jspm install npm:jquery.scrollto

and now I'm trying to import it with

import $ from 'jquery';
import scrollTo from 'jquery.scrollto';

Now I'm only getting

$(...).scrollTo is not a function

errors.

I tried to shim it, but I never did it before and can't find a good explanation how to do it, if it is necessary. Can you help me or show me a good explanation when and how do I need to shim things?

Simon Knittel
  • 1,730
  • 3
  • 15
  • 24
  • i tried minutes ago in a brand new project. `jspm install jquery`, `jspm install npm:jquery.scrollto`, then importing like you did and worked without any further action on my side. Still having this issue? – Aurelio Jun 17 '15 at 19:46
  • Yeah, I'm still having the problem. If you bundle your app with `jspm bundle-sfx app/main app.js` does it still work? Can you show me a fiddle or a small repo of your project? – Simon Knittel Jun 18 '15 at 15:48

1 Answers1

11

I tested on a clean project and here are the steps that i followed:

  1. jspm install jquery

  2. jspm install npm:jquery.scrollto -o "{format: 'global'}" - (see this answer)

  3. add the imports in my app.js as described in the question.

  4. tested both from dev mode and from a self executing bundle with no errors.

You can clone a test repo I've put up here on Github, the steps to build are in the readme. Hope this helps.

Community
  • 1
  • 1
Aurelio
  • 24,702
  • 9
  • 60
  • 63