sets data object
obj | object | data object |
update | boolean | if true, updates only changed values while the unchanged ones remain |
$$("template1").setValues({src:"imgs/image002.jpg"});
The method only makes sense if you use a template with a single data element defined for it.
For instance, you have a template object with the following configuration:
{
view:"template", //optional
id:"template1",
data:{
src:"imgs/image001.jpg",
desrc:"mytown"
},
template:function(obj){
return '<img src="'+obj.src+'"/>';
}
}
Then data from both initially defined and modified data object will be correctly displayed.
The second parameter helps manipulate values set separately. By default, it is false.
Take that we set new value for a src property from the template described above.
$$("template1").setValues({src:"imgs/image002.jpg"});
In this case, the value for the descr property is lost. To avoid this, set the update parameter to true. Template data will be updated with a new value for src property while descr value remains unchanged.
$$('template1').setValues({src:"imgs/image002.jpg"}, true);