backbone.jsrequirejsiscrolliscroll4

Use iscroll v5 with requirejs


I have a project with

  1. backbonejs
  2. requirejs

and i want to include iscroll v5 but i don't know how i can load it and init it with requirejs...

I already tried to find a solution in any fork of the project but so far i didn't find anything.

I'm a newbie in JS so i need some help with this, anyone can post an example or provide a simple demo?


Solution

  • You can include the path of the iscroll plugin in the configuration file where you declare the dependencies and paths for other files.

    require.config({
        locale: 'en_us',
    
        baseUrl: 'baseUrl',
        paths: {
            // Paths of the libraries being used
            'Iscroll' : 'relative path to the file',
            ......
            ......  Other files
        },
        shim : { // If the library does not support AMD
            'Iscroll': {
                 exports: 'Iscroll'
             },
        }
    });
    

    Now if you want to use that in a specfic Module, just include it

    define(['Iscroll', other args], function(Iscroll, other args) {
    
    });