Created
September 27, 2012 14:53
-
-
Save mdigan/3794447 to your computer and use it in GitHub Desktop.
Twitter JSON feed with JQuery, Knockout.js, and Bootstrap
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 lang="en"> | |
| <head> | |
| <title>Tweets</title> | |
| <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
| <script type="text/javascript" src="http://github.com/downloads/SteveSanderson/knockout/knockout-2.0.0.debug.js"></script> | |
| <script type="text/javascript" src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script> | |
| <link href="http://netdna.bootstrapcdn.com/bootswatch/2.1.0/spacelab/bootstrap.min.css" rel="stylesheet"> | |
| <style> | |
| body { | |
| padding: 40px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <div class="well"> | |
| <h1>Twitter JSON Feed Test</h1> | |
| </div> | |
| <h2>Some tweets | |
| <small>from mdigan</small> | |
| </h2> | |
| <table class="table table-striped table-hover"> | |
| <thead> | |
| <tr> | |
| <th>Created At</th> | |
| <th>Text</th> | |
| </tr> | |
| </thead> | |
| <tbody data-bind="foreach: results"> | |
| <tr> | |
| <td data-bind="text: created_at"></td> | |
| <td data-bind="text: text"></td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <script type="text/javascript"> | |
| var viewModel = function (data) { | |
| var self = this; | |
| self.results = ko.observableArray(); | |
| self.results(data.results); | |
| }; | |
| $(function () { | |
| $.ajax({ | |
| url:'http://search.twitter.com/search.json?q=from:mdigan', | |
| dataType:'jsonp', | |
| jsonpCallback:'_', | |
| cache:true | |
| }).error(function (a, b, c) { | |
| console.log(c); | |
| }).success(function (a, b, c) { | |
| ko.applyBindings(new viewModel(a)); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment