Created
July 13, 2012 20:17
-
-
Save kimjoar/3107158 to your computer and use it in GitHub Desktop.
Step 3 -> 4
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
| -function addStatus(options) { | |
| +var Statuses = function() { | |
| +}; | |
| +Statuses.prototype.add = function(options) { | |
| $.ajax({ | |
| url: '/status', | |
| type: 'POST', | |
| dataType: 'json', | |
| data: { text: options.text }, | |
| success: options.success | |
| }); | |
| -} | |
| +}; | |
| $(document).ready(function() { | |
| + var statuses = new Statuses(); | |
| + | |
| $('#new-status form').submit(function(e) { | |
| e.preventDefault(); | |
| - addStatus({ | |
| + statuses.add({ | |
| text: $('#new-status textarea').val(), | |
| success: function(data) { | |
| $('#statuses ul').append('<li>' + data.text + '</li>'); | |
| $('#new-status textarea').val(''); | |
| } | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment