Autosync
work with data, not with DOM
autosync.jsStandard version: IE 9+, Firefox 4.0+, Opera 12.1+, Chrome 5.0+
autosync-compat.jsExtended version: IE 6+, Firefox 1.0+, Opera 8.0+
Attributes
string
string
string
string with references to model object's fields in
{$value['field']}
formatlength
field). Also sets the first and the last element to output as the rangeNone or string in
"number1:number2"
formatpull
method must parse the element value from the JSON string (the pull method only works for <input>
and <textarea>
elements)Can take special values
"pretty"
, "pretty:<n>"
or "pretty:<str>"
for pretty JSON output, where n
is the width of each level indentation in spaces, and str
is an arbitrary prefix for each indentation level.None or string
HTML string or string in the
$([ selector ])
format, where [ selector ]
is a valid CSS selector$value
, $index
, $now
are supported)[ cond ] ? [ list1 ] | [ list2 ]
or [ cond ] ? [ list1 ]
format[ cond ] ? [ list1 ] | [ list2 ]
or [ cond ] ? [ list1 ]
format[ cond ] ? [ list1 ] | [ list2 ]
or [ cond ] ? [ list1 ]
formatevent
, value
, scope
, index
are available (if value
is not an element inside a collection, then index
is -1)Methods
as.add(model [, scope] [, key] [, atomic] [, value])
Register an object as a model
string
string or object reference
string
true / false
any
as.remove(model [, scope] [, unset])
Remove object from the models list
string
string or object reference
true / false
as.pull(model [, scope] [, update] [, url] [, key])
Update model based on the data in input elements
string
string or object reference
true / false
URL
string
as.update(model [, scope] [, key])
Force update of all elements connected to the model
string
string or object reference
string
as.setBefore(model, func, scope)
Register a new before DOM update hook. To register a global hook model must be an empty string
string
string or object reference
function
as.setAfter(model, func, scope)
Register a new after DOM update hook. To register a global hook model must be an empty string
string
string or object reference
function
as.addEvent(el, type, func, scope, value_key, keep)
Event handler registration
DOM element
string
function
string or object reference
string
true / false
as.removeEvent(el, type, func)
Event handler removal
DOM element
string
function
as.embedObject(context, str)
Embed registration
string or object reference
path.to.source:id -> path.to.dest:ref_id:field
or
path.to.source:id -> path.to.dest:ref_id:[field1 > new_field1 , field2 > new_field2]
string
as.removeEmbed(context, str, keep)
Embed removal
string or object reference
path.to.source:id -> path.to.dest:ref_id:field
or
path.to.source:id -> path.to.dest:ref_id:[field1 > new_field1 , field2 > new_field2]
string
true / false