Skip to content

Instantly share code, notes, and snippets.

@Valentino85
Created November 20, 2013 16:00
Show Gist options
  • Save Valentino85/7565610 to your computer and use it in GitHub Desktop.
Save Valentino85/7565610 to your computer and use it in GitHub Desktop.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<!--<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "Test site" %></title>
<%= csrf_meta_tags %>
</head>
<body class="home">
<script>
$(document).ready(function() {
$.getJSON( "/api/products.json", function( data ) {
var items = [];
$.each( data["products"], function( key, val ) {
items.push( "<li id='" + key + "'>" + val["name"] + "</li>" );
});
$( "<ul/>", {
"class": "my-new-list",
html: items.join( "" )
}).appendTo( "body" );
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment