API Docs for:
Show:

ModelView Class

Defined in: simple.mvc.js:230
Module: MVC

ModelView

Definition: Model: The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). View: The view manages the display of information. Source: http://bit.ly/fQnaJI

ModelView creates the glue which binds the UI(View) with the Backend code functionality of the program. It keeps the View synchronized with the 'Model'.

ModelView creates a new object with data and settings. The data and settings are (JSON) object literals and merged and returned after all the internal setup is done. The ModelView contains all the information about the object, which keeps the View synchronized with the Model and vice versa.

Constructor

ModelView

(
  • $object
  • $settings
  • $methods
)

Defined in simple.mvc.js:230

Parameters:

  • $object Object

    Model data

  • $settings Object

    Config & view input events

  • $methods Object

    Custom user defined methods/functions

Methods

_SetDataboundDomVal

(
  • datasrc
  • name
  • value
)
Object private

Update the databound elements inside or outside the View.

Parameters:

  • datasrc String

    A viewId.

  • name String

    An element's name.

  • value String

    A new value.

Returns:

Object:

The object (itself)

_SetDataboundDomVal

(
  • datasrc
  • name
  • value
)
Object private

Defined in simple.mvc.js:823

Update the databound elements inside or outside the View.

Parameters:

  • datasrc String

    A viewId.

  • name String

    An element's name.

  • value String

    A new value.

Returns:

Object:

The object (itself)

Add

(
  • listName
  • item
)
Object

Defined in simple.mvc.js:581

Add

NOTE: Must only be used if 'isMirror' is TRUE.

Adds an item to a list object in the model and updates the View.

Parameters:

  • listName String

    The object's property name

  • item String

    The new value to add to the property list

Returns:

Object:

The object (itself)

Add

(
  • listName
  • item
)
Object

Defined in simple.mvc.js:562

Remove

NOTE: Must only be used if 'isMirror' is TRUE.

Removes an item from a list object in the model and updates the View.

Parameters:

  • listName String

    The object's property name

  • item String

    The new value to add to the property list

Returns:

Object:

The object (itself)

Add

(
  • listName
  • item
)
Object

Add

NOTE: Must only be used if 'isMirror' is TRUE.

Adds an item to a list object in the model and updates the View.

Parameters:

  • listName String

    The object's property name

  • item String

    The new value to add to the property list

Returns:

Object:

The object (itself)

Add

(
  • listName
  • item
)
Object

Remove

NOTE: Must only be used if 'isMirror' is TRUE.

Removes an item from a list object in the model and updates the View.

Parameters:

  • listName String

    The object's property name

  • item String

    The new value to add to the property list

Returns:

Object:

The object (itself)

AddEvents

() Object

AddEvents

Add events to the object's input fields

Returns:

Object:

The object

AddEvents

() Object

Defined in simple.mvc.js:1015

AddEvents

Add events to the object's input fields

Returns:

Object:

The object

AddGetSet

(
  • prop
  • onUpdate
)
Object

AddGetSet

Add getter and setter methods for a property

Getters and Setters in JavaScript/JScript (ECMAScript) are not an option as it is hard to make it work cross-browser/platform! There is a solution here, but only down to IE9: Source: http://javascriptweblog.wordpress.com/2010/11/15/extending-objects-with-javascript-getters/

If changes in the model properties should be reflected in the view then setter and getter methods will be attached using jQuery.

Note: Will only be used(exec.) if 'isMirror' is TRUE.

Works in IE 7+: http://jsfiddle.net/cTJZN/

Parameters:

  • prop String

    The object's property name

  • onUpdate Function

    callBack function will execute, whenever the get/set event handlers bound with .bind() method are triggered.

Returns:

Object:

The object (itself)

AddGetSet

(
  • prop
  • onUpdate
)
Object

Defined in simple.mvc.js:436

AddGetSet

Add getter and setter methods for a property

Getters and Setters in JavaScript/JScript (ECMAScript) are not an option as it is hard to make it work cross-browser/platform! There is a solution here, but only down to IE9: Source: http://javascriptweblog.wordpress.com/2010/11/15/extending-objects-with-javascript-getters/

If changes in the model properties should be reflected in the view then setter and getter methods will be attached using jQuery.

Note: Will only be used(exec.) if 'isMirror' is TRUE.

Works in IE 7+: http://jsfiddle.net/cTJZN/

Parameters:

  • prop String

    The object's property name

  • onUpdate Function

    callBack function will execute, whenever the get/set event handlers bound with .bind() method are triggered.

Returns:

Object:

The object (itself)

AddProperty

(
  • prop
)
Object

AddProperty

Add a property to the Model

Parameters:

  • prop String

    The property name

Returns:

Object:

The object (itself)

AddProperty

(
  • prop
)
Object

Defined in simple.mvc.js:520

AddProperty

Add a property to the Model

Parameters:

  • prop String

    The property name

Returns:

Object:

The object (itself)

Clear

() Object

Clear

Clears a property's value in the Model and optionally in the View if 'isMirror' = true.

Returns:

Object:

The object (itself)

Clear

() Object

Defined in simple.mvc.js:406

Clear

Clears a property's value in the Model and optionally in the View if 'isMirror' = true.

Returns:

Object:

The object (itself)

ClearAll

() Object

Clear All

Clears all the data in the Model and the View.

Returns:

Object:

The object (itself)

ClearAll

() Object

Defined in simple.mvc.js:421

Clear All

Clears all the data in the Model and the View.

Returns:

Object:

The object (itself)

Delete

(
  • par
)
Object

Call the .Delete() method whenever you want to delete the object. Notice: This is intended behaviour, but the implementation of the method is up to the individual how and what is done when this method is called/executed.

Parameters:

  • par Object

    Provide extra parameters if needed.

Returns:

Object:

The object (itself)

Delete

(
  • par
)
Object

Defined in simple.mvc.js:392

Call the .Delete() method whenever you want to delete the object. Notice: This is intended behaviour, but the implementation of the method is up to the individual how and what is done when this method is called/executed.

Parameters:

  • par Object

    Provide extra parameters if needed.

Returns:

Object:

The object (itself)

FillSelect

(
  • prop
  • text
  • value
)
Object

Defined in simple.mvc.js:876

FillSelect

Fill select element with one or more option elements.

Parameters:

  • prop Array

    The property name which holds an array of values

  • text String

    The text to be displayed in the option element

  • value String

    The value of the option element

Returns:

Object:

The object (itself)

FillSelect

(
  • prop
  • text
  • value
)
Object

FillSelect

Fill select element with one or more option elements.

Parameters:

  • prop Array

    The property name which holds an array of values

  • text String

    The text to be displayed in the option element

  • value String

    The value of the option element

Returns:

Object:

The object (itself)

Find

() Array

Find

Find and return one or many element/s within the View using a (id or class) selector.

If the elemenet is not found an empty array is returned.

Returns:

Array:

An element from the View.

Find

() Array

Defined in simple.mvc.js:1001

Find

Find and return one or many element/s within the View using a (id or class) selector.

If the elemenet is not found an empty array is returned.

Returns:

Array:

An element from the View.

Get

(
  • prop
)
Object

Defined in simple.mvc.js:635

Get

NOTE: Must only be used if 'isMirror' is TRUE.

Parameters:

  • prop String

    The object's property name.

Returns:

Object:

value The value from the object's property.

Get

(
  • prop
)
Object

Get

NOTE: Must only be used if 'isMirror' is TRUE.

Parameters:

  • prop String

    The object's property name.

Returns:

Object:

value The value from the object's property.

GetDatasrcId

() Number

Defined in simple.mvc.js:667

GetDatasrcId

Return the (view) ID of the datasource.

Returns:

Number:

The (View) ID of the datasource.

GetDatasrcId

() Number

GetDatasrcId

Return the (view) ID of the datasource.

Returns:

Number:

The (View) ID of the datasource.

GetModelData

(
  • withSettings
)
Object

GetModelData

Return's a copy of the Model's data without it's functions. Useful when storing the data.

Note: As this object has all of it's functions/methods removed, then it's not possible to use the .toArray() (if needed for any reason) anymore. Instead use $.makeArray(theObject); which is what .toArray() uses.

Parameters:

  • withSettings Boolean

    If TRUE, then append the settings object.

Returns:

Object:

A copy of the Model's data (as JSON object literal).

GetModelData

(
  • withSettings
)
Object

Defined in simple.mvc.js:679

GetModelData

Return's a copy of the Model's data without it's functions. Useful when storing the data.

Note: As this object has all of it's functions/methods removed, then it's not possible to use the .toArray() (if needed for any reason) anymore. Instead use $.makeArray(theObject); which is what .toArray() uses.

Parameters:

  • withSettings Boolean

    If TRUE, then append the settings object.

Returns:

Object:

A copy of the Model's data (as JSON object literal).

GetViewData

() Object

Defined in simple.mvc.js:728

GetViewData

Return the View data as an JSON object literal.

Returns:

Object:

The View data as JSON object

GetViewData

() Object

GetViewData

Return the View data as an JSON object literal.

Returns:

Object:

The View data as JSON object

GetViewHtml

() Object

GetViewHtml

Returns the jQuery object.

Returns:

Object:

jQuery object.

GetViewHtml

() Object

Defined in simple.mvc.js:717

GetViewHtml

Returns the jQuery object.

Returns:

Object:

jQuery object.

GetViewId

() String

GetViewId

Get the ID of the View

Returns:

String:

The View ID

GetViewId

() String

Defined in simple.mvc.js:989

GetViewId

Get the ID of the View

Returns:

String:

The View ID

Has

(
  • prop
)
Boolean

Defined in simple.mvc.js:651

Has

Checks if the Model has a given property (true) or not (false).

Parameters:

  • prop String

    The object's property name

Returns:

Boolean:

TRUE if the property exists. Otherwise FALSE.

Has

(
  • prop
)
Boolean

Has

Checks if the Model has a given property (true) or not (false).

Parameters:

  • prop String

    The object's property name

Returns:

Boolean:

TRUE if the property exists. Otherwise FALSE.

RemoveGetSet

(
  • prop
)
Object

RemoveGetSet

Remove getter and setter methods for a property

Parameters:

  • prop String

    The object's property name

Returns:

Object:

The object (itself)

RemoveGetSet

(
  • prop
)
Object

Defined in simple.mvc.js:485

RemoveGetSet

Remove getter and setter methods for a property

Parameters:

  • prop String

    The object's property name

Returns:

Object:

The object (itself)

RemoveProperty

(
  • prop
)
Object

Defined in simple.mvc.js:542

RemoveProperty

Remove a property from the Model

Parameters:

  • prop String

    The property name

Returns:

Object:

The object (itself)

RemoveProperty

(
  • prop
)
Object

RemoveProperty

Remove a property from the Model

Parameters:

  • prop String

    The property name

Returns:

Object:

The object (itself)

RunEvent

(
  • event
)
Object

RunEvent

Trigger an event if specified in the settings.

Parameters:

  • event String

    The eventName to trigger/execute.

Returns:

Object:

The object (itself)

RunEvent

(
  • event
)
Object

Defined in simple.mvc.js:903

RunEvent

Trigger an event if specified in the settings.

Parameters:

  • event String

    The eventName to trigger/execute.

Returns:

Object:

The object (itself)

Save

(
  • par
)
Object

Call the .Save() method whenever you want to save the object. Notice: This is intended behaviour, but the implementation of the method is up to the individual how and what is done when this method is called/executed.

Parameters:

  • par Object

    Provide extra parameters if needed.

Returns:

Object:

The object (itself)

Save

(
  • par
)
Object

Defined in simple.mvc.js:364

Call the .Save() method whenever you want to save the object. Notice: This is intended behaviour, but the implementation of the method is up to the individual how and what is done when this method is called/executed.

Parameters:

  • par Object

    Provide extra parameters if needed.

Returns:

Object:

The object (itself)

Set

(
  • prop
  • value
)
Object

Defined in simple.mvc.js:599

Set

NOTE: Must only be used if 'isMirror' is TRUE.

When you need to update a value in the Model and reflect in the View.

Parameters:

  • prop String

    The object's property name

  • value String

    The new value to set for the property

Returns:

Object:

The object (itself)

Set

(
  • prop
  • value
)
Object

Set

NOTE: Must only be used if 'isMirror' is TRUE.

When you need to update a value in the Model and reflect in the View.

Parameters:

  • prop String

    The object's property name

  • value String

    The new value to set for the property

Returns:

Object:

The object (itself)

SetModelFromView

(
  • updateDataboundValues
)
Object

Defined in simple.mvc.js:774

SetModelFromView

Update the model and databound elements.

This method is internally every time a 'change' and 'keyup' event occur in form elements. This is part of the concept to always update the Model, so it is synchronized with the View.

It is possible to override the call to this method for the 'keyup' event if it is implemented manually in the settings. Therefore it's important to know that if overriding this event, but still want 'live' updating of the Model to occur, then this method must be called from the custom implementation of the 'keyup' event!

Parameters:

  • updateDataboundValues Boolean

    TRUE | FALSE - If undefined or true, databound elements inside and/or outside the the View will also get updated. If false, then they won't.

Returns:

Object:

The object (itself)

SetModelFromView

(
  • updateDataboundValues
)
Object

SetModelFromView

Update the model and databound elements.

This method is internally every time a 'change' and 'keyup' event occur in form elements. This is part of the concept to always update the Model, so it is synchronized with the View.

It is possible to override the call to this method for the 'keyup' event if it is implemented manually in the settings. Therefore it's important to know that if overriding this event, but still want 'live' updating of the Model to occur, then this method must be called from the custom implementation of the 'keyup' event!

Parameters:

  • updateDataboundValues Boolean

    TRUE | FALSE - If undefined or true, databound elements inside and/or outside the the View will also get updated. If false, then they won't.

Returns:

Object:

The object (itself)

SetViewData

() Object

SetViewData

Set the View data from the Model (does not update databound elments)

Returns:

Object:

The object (itself)

SetViewData

() Object

Defined in simple.mvc.js:742

SetViewData

Set the View data from the Model (does not update databound elments)

Returns:

Object:

The object (itself)

SetViewFromModel

()

Defined in simple.mvc.js:755

SetViewFromModel

Updates the elements in the View from the Model (including databound elements).

SetViewFromModel

()

SetViewFromModel

Updates the elements in the View from the Model (including databound elements).

Start

(
  • method
  • par
)
Object

Start

Execute a method in the controller.

Parameters:

  • method String

    The methods name specified in the controller.

  • par Object

    If needed you can provide optional parameters.

Returns:

Object:

The object (itself)

Start

(
  • method
  • par
)
Object

Defined in simple.mvc.js:948

Start

Execute a method in the controller.

Parameters:

  • method String

    The methods name specified in the controller.

  • par Object

    If needed you can provide optional parameters.

Returns:

Object:

The object (itself)

toArray

() Array

toArray

Convert the object to a real Array.

Returns:

Array:

The object converted into a real Array.

toArray

() Array

Defined in simple.mvc.js:977

toArray

Convert the object to a real Array.

Returns:

Array:

The object converted into a real Array.

TriggerEvent

(
  • prop
  • evt
)
Object

Defined in simple.mvc.js:502

Trigger Event

Trigger an event on an input element inside the view

Parameters:

  • prop String

    Property name

  • evt String

    Event type/name (e.g. 'keyup')

Returns:

Object:

The object (itself)

TriggerEvent

(
  • prop
  • evt
)
Object

Trigger Event

Trigger an event on an input element inside the view

Parameters:

  • prop String

    Property name

  • evt String

    Event type/name (e.g. 'keyup')

Returns:

Object:

The object (itself)

Update

(
  • par
)
Object

Defined in simple.mvc.js:378

Call the .Update() method whenever you want to update the object. Notice: This is intended behaviour, but the implementation of the method is up to the individual how and what is done when this method is called/executed.

Parameters:

  • par Object

    Provide extra parameters if needed.

Returns:

Object:

The object (itself)

Update

(
  • par
)
Object

Call the .Update() method whenever you want to update the object. Notice: This is intended behaviour, but the implementation of the method is up to the individual how and what is done when this method is called/executed.

Parameters:

  • par Object

    Provide extra parameters if needed.

Returns:

Object:

The object (itself)

Events

keyup ...

keyup event

It's important to know that when overriding this event, but still want 'live' updating of the Model to occur, then this method must be called from the custom implementation of the 'keyup' event!

keyup ...

Defined in simple.mvc.js:1050

keyup event

It's important to know that when overriding this event, but still want 'live' updating of the Model to occur, then this method must be called from the custom implementation of the 'keyup' event!