JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css">
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap.js"></script>
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="#">Netflix</a>
</div>
</div>
<form>
<fieldset>
<legend>Movie Search</legend>
<label>Search Term</label>
<input type="text" placeholder="Type movie…">
<span class="help-block">Example: <a class="term" href="#">Star Wars</a></span>
<button type="submit" class="btn">Search</button>
</fieldset>
</form>
<table class="table table-striped table-condensed" hidden>
<caption>Search Results</caption>
<thead>
<tr>
<th>Name</th>
<th>Rating</th>
<th>Released</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
JavaScript
$( document ).on( "click", ".term", function( e ) {
e.preventDefault();
$( "input" ).val( $( this ).text() );
$( "button" ).trigger( "click" );
});
$( "button" ).on( "click", function( e ) {
var searchTerm = $( "input" ).val();
var url = "http://odata.netflix.com/Catalog/Titles?$filter=substringof('" + escape( searchTerm ) + "',Name)&$callback=callback&$format=json";
$( ".help-block" ).html( function( index, html ) {
return e.originalEvent ? html + ", " + "<a href='#' class='term'>" + searchTerm + "</a>" : html;
});
$.ajax({
dataType: "jsonp",
url: url,
jsonpCallback: "callback",
success: function( data ) {
var rows = [];
$.each( data.d.results, function( index, result ) {
var row = "";
if ( result.Rating && result.ReleaseYear ) {
row += "<td>" + result.Name + "</td>";
row += "<td>" + result.Rating + "</td>";
row += "<td>" + result.ReleaseYear + "</td>";
row = "<tr>" + row + "</tr>";
rows.push( row );
}
});
$( "table" ).show().find( "tbody" ).html( rows.join( "" ) );
}
});
e.preventDefault();
});