API Docs for: 0.0.2
Show:

dataSource.JSON Class

Class for remote data source.

Methods

getData

() Success:true, data:

Return data loaded from server

Returns:

Success:true, data:: object data from server, example:

getSourceType

()

Return data-source type(HTML or JSON)

Returns:

string source type

hasData

() Boolean

Has data loaded from server

Returns:

load

()

Reload data from server Components using this data-source will be automatically updated

Returns:

void

loadUrl

(
  • url
)

Load content from a specific url

Parameters:

sendRequest

(
  • service
  • arguments
  • data
)

Send a new request

Parameters:

Attributes

arguments

Array

Array of arguments to send to resource on server

Default: '' Here are some examples: Create a data source for server resource "Person", service name "load" and id : "1". You will then set these config properties:

Example:

     "resource": "Person",
     "service": "load",
     "arguments": [1]

autoload

Boolean

Load data from external source on creation

Default: true

Fires event autoloadChange

Fires when the value for the configuration attribute autoload is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

object postData

Remote postData sent with request, example: postData: { getUsers: 1 }

Fires event object postDataChange

Fires when the value for the configuration attribute object postData is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

resource

String

Name of resource to request on the server

Default: ''

service

String

Name of service to request on the server

Default: ''

shim

Object

Config of shim to show when content is being loaded form server. This config object supports two properties, "renderTo" and "txt". renderTo is optional and specifies where to render the shim. Default is inside body of parent view. "txt" specifies which text to display inside the shim. "txt" can be either a string or a function returning a string.

Example:

shim:{
        renderTo:ludo.get('myView').getBody(),
        txt : 'Loading content. Please wait'
}

renderTo is optional. Example where "txt" is defined as function:

shim:{
    "txt": function(){
        var val = ludo.get('searchField).getValue();
        return val.length ? 'Searching for ' + val : 'Searching';
    }
}

singleton

Boolean

Accept only one data-source of this type. You also need to specify the "type" property which will be used as key in the global SINGELTON cache By using singletons, you don't have to do multiple requests to the server

Fires event singletonChange

Fires when the value for the configuration attribute singleton is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

url

String optional

Remote url. If not set, global url will be used

Fires event urlChange

Fires when the value for the configuration attribute url is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

Events

failure

Event fired when success parameter in response from server is false

Event Payload:

  • JSON Object

    response from server. Error message should be in the "message" property

  • this ludo.dataSource.JSON

servererror

Server error event. Fired when the server didn't handle the request

Event Payload: