Classes
Members
(static) queue :array
An array with the identification of
all the controllers to be queried through
Ajax
(static) validation :object
An object similar
to Sf.view, with the callable functions
used to validate FORMS
(static) view :object
An object with the callable functions of
all the views to be rendered.
Methods
(static) add_validation(obj, funct)
A wrapper to associate a callback
function of a "validation" resource
to a specified scope and namespace
Parameters
Name | Type | Description |
---|---|---|
obj |
object | An object in this form: {scope: [scope], namespace: [namespace], label: [label]} (the identification of the validation function) |
funct |
function | The callback function with the various validations methods |
(static) add_view(obj, funct)
This function is called by a view
to associate the related code to
a specified scope and namespace
Parameters
Name | Type | Description |
---|---|---|
obj |
object | An object in this form: {scope: [scope], namespace: [namespace], label: [label]} |
funct |
function | The callback function with the various view's elements |
(static) client_side() → {bool}
A "negative" alias of the function above:
check if the script is executed client-side
Returns
Returns true if client side and false if
server side
- Type
- bool
(static) get_data(obj) → {object}
Interface to the controller's data
Parameters
Name | Type | Description |
---|---|---|
obj |
object | An object of the resource (in this case a controller) identification. It should be in this form: {scope: [scope], namespace: [namespace], label: [label]} |
Returns
The result taken server-side from the
controller
If executed server side the function directly queries
the controller, while if executed client side the function
queues the controller's identification and queries the
server only once through Ajax (see above)
- Type
- object
(static) render(obj) → {string}
The main rendering function
Parameters
Name | Type | Description |
---|---|---|
obj |
object | An object in this form: {scope: [scope], namespace: [namespace], label: [label]} (the identification of the element to be rendered) |
Returns
The output html/text string
- Type
- string
(static) restore_data(context, data)
This function will restore client-side
the controllers data used server-side
at run-time
Parameters
Name | Type | Description |
---|---|---|
context |
string | Can be "data" or "html": "data" are the controllers data and "html" the data related to the HTML elements (see Html.js: we allow the use of javascript objects as element's attributes, without the need to encode them within the HTML element itself) |
data |
object | A base64 encoded stringified JSON object --- such data will be written in the static HTML document inside a script tag |
(static) server_side() → {bool}
Check if the script is executed server side
Returns
Returns true if server side and false if
client side
- Type
- bool
(static) update(parent_el)
This is the function used to update the view
To Do
- Rather than to call the function specifying an event on the HTML element itself, the call to the function should be implemented through some custom "sf" attribute, for instance in the following way: sf-update="[event]" where event can be "onclick", "onchange", and so on. (Then on DOM ready the function will be attached to the element with the specified event)
Parameters
Name | Type | Description |
---|---|---|
parent_el |
element | The DOM element to which is attached the event which fires the function |