Add data to render each menu item
This commit is contained in:
parent
8d65d9325c
commit
edd5396500
@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"Sandwiches": "",
|
"collection": "sandwiches",
|
||||||
|
"title": "Sandwiches",
|
||||||
"entrees": [
|
"entrees": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "Bánh Mì",
|
||||||
"description": "",
|
"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": ""
|
"price": 14
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
13
index.html
13
index.html
@ -38,5 +38,18 @@
|
|||||||
|
|
||||||
<h4>Phone</h4>
|
<h4>Phone</h4>
|
||||||
<a href="tel:+13603855275">360.385.5275</a>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
34
scripts/index.js
Normal file
34
scripts/index.js
Normal 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
1920
scripts/lib/backbone.js
Normal file
File diff suppressed because it is too large
Load Diff
1692
scripts/lib/underscore.js
Normal file
1692
scripts/lib/underscore.js
Normal file
File diff suppressed because it is too large
Load Diff
1
templates/menu.mst
Normal file
1
templates/menu.mst
Normal file
@ -0,0 +1 @@
|
|||||||
|
<h3>{{ title }}</h3>
|
||||||
Loading…
x
Reference in New Issue
Block a user