Class: SGModelView

SGModelView()

SGModelView 1.0.3 Add-on over SGModel that allows you to bind data in JavaScript with visual elements of HTML document using MVVM pattern.

Constructor

new SGModelView()

License:
  • SGModel may be freely distributed under the MIT license
Source:
See:

Extends

Methods

bindHTML(rootopt)

Perform Data and View Binding (MVVM)

Parameters:
Name Type Attributes Default Description
root string | HTMLElement <optional>
void 0

Example "#my_div_id" or HTMLElement object

Source:

defaults() → {object}

Sets the default property values. Overriden

Inherited From:
Source:
Returns:
Type
object

destroy()

Destroy the instance

Inherited From:
Source:

get()

Get property value

Inherited From:
Source:

has()

Check if there is a property in the model

Inherited From:
Source:

initialize()

Called when an instance is created. Override in your classes

Inherited From:
Source:

off(name, func)

Remove trigger on property change

Parameters:
Name Type Description
name string | array
func function
Inherited From:
Source:

on(name, func, context, data, flags)

Set trigger for property change

Parameters:
Name Type Default Description
name string | array
func function
context object

If not specified, the this of the current object is passed

data mixed

If data is set, then this value (data) is passed in the first arguments [] callback

flags number 0

Valid flags: SGModel.FLAG_IMMEDIATELY - func will be executed once now

Inherited From:
Source:

save()

Save instance data to local storage

Inherited From:
Source:

set(name, val, optionsopt, flagsopt) → {boolean}

Set property value. Overriding the SGModel#set method

Parameters:
Name Type Attributes Default Description
name string
val mixed
options object <optional>
void 0
Properties
Name Type Attributes Description
precision number <optional>

Rounding precision

previous_value mixed <optional>

Use this value as the previous value

flags number <optional>
0

Valid flags: FLAG_OFF_MAY_BE | FLAG_PREV_VALUE_CLONE | FLAG_NO_CALLBACKS | FLAG_FORCE_CALLBACKS | FLAG_IGNORE_OWN_SETTER

Overrides:
Source:
Returns:

If the value was changed will return true

Type
boolean

setOnAllCallback(func, flags)

Set trigger to change any property

Parameters:
Name Type Default Description
func function
flags number 0

Valid flags: SGModel.FLAG_IMMEDIATELY - func will be executed once now

Inherited From:
Source:

trigger(name, flags)

Execute callbacks that are executed when the property value changes

Parameters:
Name Type Default Description
name string
flags number 0

Valid flags: SGModel.FLAG_OFF_MAY_BE - if set can be .off(), then you need to pass this flag

Inherited From:
Source: