ractive.updateModel()
edit this pageIf you programmatically manipulate inputs and other elements that have two‐way binding set up, your model can get out of sync. In these cases, we need to force a resync with ractive.updateModel():
ractive = new Ractive({
el: 'container',
template: '<input value="">'
data: { name: 'Bob' }
});
ractive.find( 'input' ).value = 'Jim';
alert( ractive.get( 'name' ) ); // alerts 'Bob', not 'Jim'
ractive.updateModel();
alert( ractive.get( 'name' ) ); // alerts 'Jim'
ractive.updateModel( keypath [, cascade ])
keypath
StringThe keypath to treat as 'dirty'. Any two-way bindings linked to this keypath will be checked to see if the model is out of date
cascade
BooleanIf true, bindings that are downstream of
keypathwill also be checked - e.g.ractive.updateModel( 'items', true )would checkitems.0.fooanditems.1.fooand so on. Defaults tofalse.ractive.updateModel()
If a
keypathis not specified, all two-way bindings will be checked.