jsbeans

jsbeans  1.0.0

jsbeans > jsbeans > jsbeans.mvc.view
Search:
 
Filters

static Class jsbeans.mvc.view

Loads and store views.
It contains useful methods to achieve performance and a simple XmlHttpRequest Object to decouple the framework from any external library.

Properties

cache - static Array

A local cache of loaded views. Turns to be optimal for performance reasons.
Default Value: []

inline - static Boolean

Tells if a view is in an inline script tag.
Default Value: false

templatePath - static String

Stores value of the path where templates (views) are found
Default Value: null

Methods

fetch

static void fetch ( view )
A preloader for templates.
May accept a single name or an Array of names. As {@method} load it uses queue for remote templates.
Parameters:
view <String | Array> the view, or views in case of Array, to load
Returns: void

load

static void load ( view , callback )
Loads templates in two different ways:
  1. remotely from server (via a GET)
  2. locally in page (via a document.getElementById)
and stores them locally.
In the first case templates must be located as defined in data-templatePath custom attribute of view script tag, in the second one you must use the custom attribute inline set to true.
You cannot use both in a mixed way. In other words choose your storage: remote XOR local. Local takes priority over remote if both defined.
To prevent errors remote calls are enqueued in a FIFO. If a call is in progress waits 50ms before retrying.
Parameters:
view <String> the name of the view to be loaded. For remote views the file must have html extension.
callback <Function> a function fired after template is loaded
Returns: void

xhr

static xhr ( )
Create, then stores, and returns a XmlHttpRequest Object.


Copyright © 2016 Francesco Mele. All rights reserved.