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

Defining the app.js file


When we defined the RequireJS configuration, we said that the entry point will be the app.js file. The following are the steps to create the app.js file:

  1. Create the app.js file.

  2. Set the array of dependencies. Map these dependencies as arguments in the function. There are some files that just execute code and they return an undefined value. You don't need to map these files if they are at the end of the list of dependencies.

    define([
      //LIBRARIES
      'bootstrap',
      'knockout',
      'koAmdHelpers',
      'ko.validation',
      'icheck',
    
      //VIEWMODEL
      'viewmodel',
    
      //MOCKS
      'mocks/product',
      'mocks/order',
    
      //COMPONENTS
      'custom/components',
    
      //BINDINGS
      'custom/koBindings',
    
      //EVENTS
      'events/cart'
    ], function(bs, ko, koValidation, koAmdHelpers, 'iCheck', 'ViewModel) {
    });
  3. Now define the body of the module. It will initialize global configurations and global behaviors. Finally, it will return the view-model:

    define([...],function(...){
      //ko External Template Settings...