Skip to content

Instantly share code, notes, and snippets.

@mattborn
Last active December 7, 2015 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattborn/1be6fb9eb21f47fe0f26 to your computer and use it in GitHub Desktop.
Save mattborn/1be6fb9eb21f47fe0f26 to your computer and use it in GitHub Desktop.
Simple SPA
# editorconfig.org
root = true
[*]
charset = utf-8
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Simple SPA</title>
</head>
<body>
<a href="#page1">Page 1</a>
<a href="#page2">Page 2</a>
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
<script src="script.js"></script>
</body>
</html>
<style>
h1 { color: blue; }
</style>
<h1>Page 1</h1>
<script>
alert('this is page 1');
</script>
<h1>Page 2</h1>
$(function() {
$('#root').load('page1.html');
$('a').click(function (e) {
e.preventDefault();
$('#root').load(this.hash.substring(1) + '.html');
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment