Building Enterprise HTML5 Application

brite.display

Instantiate and Display a View.

brite.display(viewName,parent)

brite.display(viewName,parent,data)

brite.display(viewName,parent,data,configOverride)

  • viewName {string} : The unique name of the view (i.e. "ProjectView")
  • parent {element} : An HTML Element, jQuery element, or jQuery selector of a single element to which this view.$el will be added to. If undefined or null, the view config.parent will be taken in account. If config.parent is null or undefined as well, then, the view.$el will have to be added manually on postDisplay or on the done(function(view){...}) callback. Most of the time, this parameter will be defined.
  • data {object} : Any data the view might need to render itself. If no data is needed but a configOverride is, then, this must be null.
  • configOverride {object} : Object that will override the values set by the registerView for this view. parent and emptyParent properties can be overriden. See brite.registerView for more info.

returns {Promise} Return a Deferred Promise that will get resolved with the View instance object after the postDisplay.

Examples

// will display the ProjectView view in the $someDiv jQuery HTML element 
brite.display("ProjectView","#someDiv",{projectId:123}});

// or using a jQuery element and telling to emptyParent before appending it 
// Note: The config.emptyParent:true would usually be defined in the registerView config. 
var $someDiv = $("#someDiv");
brite.display("ProjectView",$someDiv,{projectId:123});

// View are asynchronously managed, so, can register a Deferred callback after create,init, and postDisplay are completed
brite.display("ProjectView","#someDiv",{projectId:123}}).done(function(projectView){
  console.log("New ProjectView created with instanceUniqueId " + projectView.id + " and element: " + projectView.$el);  
});

// Note: by convention, any variables or properties starting with '$' are a jQuery object wrapping one or more HTMLElements.

Ask, learn, share about brite.js

Go to brite.js G+ community