Created
July 29, 2013 16:12
-
-
Save pads/6105476 to your computer and use it in GitHub Desktop.
Quick spike of using an AJAX include pattern to load tiddlers as content in a page, based on tag and title.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Ajax Include Spike</title> | |
</head> | |
<body> | |
<div data-tiddlers="fragment"> | |
<div data-tiddler="Fragment2">tiddler two loaded here</div> | |
<div data-tiddler="Fragment3">tiddler three loaded here</div> | |
<div data-tiddler="Fragment1">tiddler one loaded here</div> | |
<div data-tiddler="Fragment4">tiddler four loaded here</div> | |
</div> | |
<script src="http://code.jquery.com/jquery-1.10.2.js"></script> | |
<script> | |
var tag = $("[data-tiddlers]").data("tiddlers"); | |
var tiddlers = {}; | |
$.getJSON("http://tiddlyspace.com/search.json?q=tag:" + tag + "&fat=1&render=1", function(data) { | |
$(data).each(function(index, value) { | |
tiddlers[value.title] = value.render ? value.render : value.text; | |
}); | |
$("[data-tiddler]").each(function(index, value) { | |
var title = $(this).data("tiddler"); | |
$(this).html(tiddlers[title]); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment