Skip to content

Instantly share code, notes, and snippets.

@vadimdemedes
Last active December 15, 2015 20:40
Show Gist options
  • Save vadimdemedes/5320074 to your computer and use it in GitHub Desktop.
Save vadimdemedes/5320074 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Example view</title>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="//s3.amazonaws.com/cdn.getchute.com/chute-js/v1/chute.min.js" data-load="view"></script>
<script class="editor-template" type="application/x-template">
<div class="editor-view">
<textarea></textarea>
<span class="word-counter">0 words</span>
</div>
</script>
<script>
Chute.ready(function(){
var EditorView = Chute.View.extend({
template: 'script.editor-template',
dependencies: ['style.css'],
handlers: {
'keyup textarea': 'countWords'
},
ui: {
'textbox': 'textarea',
'wordCounter': 'span.word-counter'
},
countWords: function() {
var words = this.ui.textbox.val().split(' ').length;
this.ui.wordCounter.text(words + ' words');
}
});
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment