Skip to content

Instantly share code, notes, and snippets.

@teaplanet
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save teaplanet/8a4d90ccb506be7726de to your computer and use it in GitHub Desktop.

Select an option

Save teaplanet/8a4d90ccb506be7726de to your computer and use it in GitHub Desktop.
Ractive.js Tutorial 4-4
<!-- http://learn.ractivejs.org/conditional-sections/4 -->
<script src='http://cdn.ractivejs.org/latest/ractive.min.js'></script>
<script src='https://raw.github.com/ractivejs/ractive-events-tap/master/ractive-events-tap.js'></script>
<div id='container'></div>
<script id='template' type='text/ractive'>
<button on-tap='activate'>Activate!</button>
<button on-tap='deactivate'>Deactivate!</button>
<button on-tap='silence'>Silence!</button>
</script>
var ractive = new Ractive({
el: 'container',
template: '#template'
});
listener = ractive.on({
activate: function() {
alert('Activating!' );
},
deactivate: function() {
alert('Deactivating!');
},
silence: function() {
alert('No more alerts!');
listener.cancel();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment