Add data to render each menu item

This commit is contained in:
Nathan Chapman 2018-10-16 21:45:13 -07:00
parent 8d65d9325c
commit edd5396500
6 changed files with 3665 additions and 4 deletions

View File

@ -1,10 +1,11 @@
{
"Sandwiches": "",
"collection": "sandwiches",
"title": "Sandwiches",
"entrees": [
{
"name": "",
"description": "",
"price": ""
"name": "Bánh Mì",
"description": "Slow roasted pork belly, with fresh pickled carrots, onion and cucumbers with jalapeños, red peppers and cilantro on panini bread with sweet chili mayo.",
"price": 14
}
]
}

View File

@ -38,5 +38,18 @@
<h4>Phone</h4>
<a href="tel:+13603855275">360.385.5275</a>
<div id="container">
<h3>{{ menu.title }}</h3>
<ul>
<li v-for="item in menu.entrees">
{{ item.name }}: {{ item.description }}
</li>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="/scripts/index.js"></script>
</body>
</html>

34
scripts/index.js Normal file
View File

@ -0,0 +1,34 @@
// When the DOM is ready it'll execute fn().
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
ready(function() {
var getFile = function(url, cb) {
var request = new XMLHttpRequest();
request.open('GET', url, false);
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
// Success!
var json = JSON.parse(this.response);
var app = new Vue({
el: '#container',
data: {
menu: json
}
});
} else {
console.log("We reached our target server, but it returned an error");
}
};
request.onerror = function() {
console.log("There was a connection error of some sort");
};
request.send();
};
var data = getFile('/data.json');
});

1920
scripts/lib/backbone.js Normal file

File diff suppressed because it is too large Load Diff

1692
scripts/lib/underscore.js Normal file

File diff suppressed because it is too large Load Diff

1
templates/menu.mst Normal file
View File

@ -0,0 +1 @@
<h3>{{ title }}</h3>