JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/mikeric/rivets/v0.3.8/lib/rivets.min.js"></script>
<div id="editItemDialog" data-modal="store.ActiveItem">
<a data-on-click="store:ClearActiveItem" href="#">close - works</a>
<div>
<div>
<label>name:</label><input data-value="store.ActiveItem.Name < store.ActiveItem"/>
</div>
<div>
<label>price:</label><input data-value="store.ActiveItem.Price < store.ActiveItem"/>
</div>
<div>
<label>description:</label><textarea data-value="store.ActiveItem.Description < store.ActiveItem"></textarea>
</div>
</div>
</div>
CoffeeScript
# Include https://raw.github.com/mikeric/rivets/v0.3.8/lib/rivets.min.js
class StoreModel
ActiveItem:
Name: 'Car'
Price: 123
Description: 'A lovely blue vehicle'
ClearActiveItem: ->
alert 'Click!'
storeInstance = new StoreModel
rivets.configure
adapter:
subscribe: (obj, keypath, callback) ->
# Our simple model does not support subscriptions
unsubscribe: (obj, keypath, callback) ->
# As above
read: (obj, keypath) ->
index = keypath.indexOf '.'
if index > -1
pathA = keypath[0...index]
pathB = keypath[index+1...]
return obj[pathA][pathB]
else
return obj[keypath]
publish: (obj, keypath, value) ->
index = keypath.indexOf '.'
if index > -1
pathA = keypath[0...index]
pathB = keypath[index+1...]
obj[pathA][pathB] = value
else
obj[keypath] = value
rivets.bind $('#editItemDialog'), store: storeInstance