Skip to content

Instantly share code, notes, and snippets.

@TheBits
Created August 23, 2012 15:56
Show Gist options
  • Save TheBits/3437965 to your computer and use it in GitHub Desktop.
Save TheBits/3437965 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<script src="http://yandex.st/jquery/1.8.0/jquery.min.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
<script src="rivets.js"></script>
</head>
<body>
<div id='auction'>
<h1 data-text='auction.title'></h1>
</div>
<script>
var auction = new Backbone.Model;
auction.set('title', 'hi');
// auction.on('change', function(){console.log('change-change')});
rivets.configure({
adapter: {
subscribe: function(model, key, callback){
console.log('subscr', arguments);
callback.wrap = function(a, b) {
console.log('wrap',a, b);
callback(b);
};
model.on('change:'+key, callback.wrap);
},
read: function(obj, key) {
console.log('read', arguments, obj.get(key));
return obj.get(key);
}
}
});
rivets.bind(document.getElementById('auction'), {auction: auction});
auction.set('title', 'ok');
auction.set('title', 'okkk');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment