I came across rivets library and tried to do simple example. But I had 2 issues:
- In tutorial they write "user.name" (with dot) but for me it works only if I write "user:name"
- When I change the user.name property why DOM doesn't change?
The code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Example</title>
<script src="/js/rivets.min.js"></script>
<script src="/js/jquery-2.0.0.min.js"></script>
<script>
$(function() {
var user = {
name: 'User'
}
$('#userName').keyup(function() {
user.name = $('#userName').val();
});
rivets.bind($('#user'), { user:user })
});
</script>
</head>
<body>
<input type="text" id="userName" />
<div id="user">
<p data-text="user:name"></p>
</div>
</body>
</html>