API Docs for: 0.1.0
Show:

zerk.jsonLoader Class

Module: zerk

JSON Loader

Loads JSON resources via Ajax.

Methods

_getResourcePath

(
  • id
)
String protected

Returns the path for given resource id

This method is using the namespace configuration.

Parameters:

  • id String

    Resource id

Returns:

String: Path to resource

getResource

(
  • id
)
Object

Returns a preloaded resource

Parameters:

  • id String

    Resource id

Returns:

Object: The resource data

init

(
  • config
)

Class constructor

Parameters:

  • config Object

    Configuration object

isLoaded

(
  • id
)
Boolean

Returns true when resource is loaded already

Parameters:

  • id String

    Resource id

Returns:

Boolean: True when the resource is loaded already

loadResource

(
  • resource
  • successHandler
  • errorHandler
)
async

Loads one resource

Fires successHandler when the resource is loaded.

Parameters:

  • resource String

    Resource id

  • successHandler Function

    Event handler for success

  • errorHandler Function

    Event handler for error

require

(
  • resources
  • successHandler
  • errorHandler
)
async

Loads multiple resources

Fires successHandler when all resources are loaded.

Parameters:

  • resources Array

    Array of resource id's

  • successHandler Function

    Event handler for success

  • errorHandler Function

    Event handler for error

setConfig

(
  • config
)

Sets the namespace configuration

Parameters:

  • config Object

    Configuration object

Properties

_ajax

zerk.network.ajax protected

AJAX interface to load the resources

_data

Object protected

Register of loaded resources

_namespace

Object protected

Namespace configuration