Book Image

Knockout.JS Essentials

Book Image

Knockout.JS Essentials

Overview of this book

Table of Contents (16 chapters)
KnockoutJS Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring RequireJS


To configure RequireJS, create a file at the same level as the viewmodel.js file lies. You can call it main.js, and follow these steps:

  1. Define the basic config method:

    require.config({
    
    });
  2. Then, define the base URL for the scripts. This is where RequireJS will look for scripts:

    Require.config({
    baseUrl:'js'
    });
  3. Now, define aliases for the paths of the vendor libraries in the paths attribute. This helps you to avoid writing long paths in our module dependencies. You don't need to define the extension. RequireJS adds the extension for you:

    require.config({
      baseUrl:'js',
      paths: {
        bootstrap:'vendors/bootstrap.min',
        icheck: 'vendors/icheck',
        jquery: 'vendors/jquery.min',
        mockjax: 'vendors/jquery.mockjax',
        mockjson: 'vendors/jquery.mockjson',
        knockout  : 'vendors/knockout.debug',
        'ko.validation':'vendors/ko.validation',
        'ko-amd-helpers': 'vendors/knockout-amd-helpers',
        text: 'vendors/require.text'
      }
    });
  4. Also, define dependencies inside...