new Suit.model()
Reference to the container of Model features.
Methods
-
staticSuit.model.data(target, value){Object}
-
Get/Set a View's data in object format.
Name Type Description target
String | Element Path or reference to the target.
value
Object nullable Value to set the target or null if the method must only return the value.
- See:
Returns:
Type Description Object - Returns the Object formatted data of the Element instance.
Example
<div n='content'> <p n='title>Title</p> <input type='text' n='name' value='John'> </div>
//Get
Suit.model.data("content"); //returns {title: "Title", name: "John"}
Suit.model.data("content.title"); //returns "Title"
Suit.model.data("content.name"); //returns "John"//Set
Suit.model.data("content",{title: "New Title", name: "Carl"}); //returns {title: "New Title", name: "Carl"}<!-- updated dom --> <div n='content'> <p n='title>New Title</p> <input type='text' n='name' value='Carl'> </div>
-
staticSuit.model.value(target, value){String|Number|Object}
-
Get/Set the correct 'value' of a primitive Element (i.e. input, select, ...).
Name Type Description target
String Path or reference to the target.
value
Objet nullable Value to set the target or null if the method must only return the value.
- See:
Returns:
Type Description String | Number | Object - Returns the raw value of the Element.
Example
<input type='text' value='Text' n='field'> <input type='checkbox' checked='false' n='toggle'>
//Get
Suit.model.value("field"); //returns "Text"
Suit.model.value("toggle"); //returns "false"//Set
Suit.model.value("field","New Text"); //returns "New Text"
Suit.model.value("toggle",true); //returns "true"<!-- updated dom --> <input type='text' value='New Text' n='field'> <input type='checkbox' checked='true' n='toggle'>