Skip to content

Instantly share code, notes, and snippets.

@pinscript
Created September 5, 2011 14:49
Show Gist options
  • Save pinscript/1195162 to your computer and use it in GitHub Desktop.
Save pinscript/1195162 to your computer and use it in GitHub Desktop.
<html>
<head>
<style>
div { border: 1px dashed orange; padding: 10px; display: none; margin-bottom: 20px; }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("[data-publish]").click(function() {
var eventName = $(this).data('publish');
var subscribers = $("[data-subscribe='" + eventName + "']");
$.each(subscribers, function() {
var subscriber = $(this);
var func = $(this).data("on-subscription");
subscriber[func]();
});
});
});
</script>
</head>
<body>
<ul>
<li data-publish="links">Länkar</li>
<li data-publish="content">Content</li>
</ul>
<div data-subscribe="links" data-on-subscription="toggle">
Vi har riktat länkar mot din sida...
</div>
<div data-subscribe="links" data-on-subscription="toggle">
Om du byter adress, var vänlig säg till oss så vi kan uppdatera våra länkar..
</div>
<div data-subscribe="content" data-on-subscription="toggle">
Textinnehåll är viktigt...
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment