Created
August 26, 2011 01:54
-
-
Save amundo/1172515 to your computer and use it in GitHub Desktop.
trying to figure out hwo to make events do something
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>events</title> | |
| <meta charset="UTF-8"> | |
| <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
| <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.1.7/underscore-min.js"></script> | |
| <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.5.3/backbone-min.js"></script> | |
| <script> | |
| $(document).ready(function(){ | |
| window.PasteView = Backbone.Model.extend({ | |
| el : '#paste', | |
| events : { | |
| 'keyup ' : 'callback', | |
| 'keydown ' : 'callback', | |
| 'keypress ' : 'callback' | |
| }, | |
| initialize: function(){ | |
| _.bindAll(this, 'render', 'callback'); | |
| }, | |
| render: function(){ | |
| }, | |
| callback : function(){ | |
| console.log( 'you keyupped' ) ; | |
| } | |
| }); | |
| window.paste = new PasteView; | |
| }) | |
| </script> | |
| </head> | |
| <div id="paste"> | |
| <p>Every time you hit a key there should be a console.log event</p> | |
| <textarea id="text" ></textarea> | |
| </div> | |
| </body> | |
| </html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment