Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
// Example Widget
function(app, ns/*, data, utils*/){
    // Create Widget short name for local reference    exWdgt = {};

    // Use closures for private code    var testFunc();

    // Add all widget code to widget namespace.
    exWdgtns.WidgetModel = can.Model({...});
    exWdgtns.WidgetControl = can.Control({...});

    // Add an initialization function if the widget should be initialized externally
    exWdgtns.initWidget = function(/*params*/){...};

    // Make sure to add widget namespace to ns namespace
    ns.ExampleWidget = exWdgt;

// Pass in external values that will be used by this code
}(
// ns should always be included, be first and be theraft.app,              // The app namespace
raft.widgets.ExWidget, // The specific namespace to which the resulting objects and functions from this file will be added.
raft.data.widgetsExWidget,    // ns
raft.data,    // dataThe specific data namespace for this widget/page/object. Cached and local data  should go here
raft.utils             // utils The namespace containing app framework utilities
));

$(document).ready(function()){
    // Code to run when document is finished loading
}

...