Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created June 22, 2009 16:50
Show Gist options
  • Save subtleGradient/134072 to your computer and use it in GitHub Desktop.
Save subtleGradient/134072 to your computer and use it in GitHub Desktop.
var btn = new Element('button',{html:'Run'}).addEvent('click', Context('dynamic').handleWith('handleClick'));
Ccontext(1).addHandler('handleClick', function(){alert(1);});
Ccontext(2).addHandler('handleClick', function(){alert(2);});
Context.set(1);
Context('dynamic') === Context(1);
btn.fireEvent('click'); // alert(1)
Context.set(2);
Context('dynamic') === Context(2);
btn.fireEvent('click'); // alert(2)
// # -- sequential speccing
spec.group('id', 'description');
spec.add('some description', function(){});
spec.add('some other description', function(){});
spec.group('id2', 'description2');
spec.add('some description', function(){});
spec.add('some other description', function(){});
spec.run(); //starts every group
spec.run('id'); //starts the group id
spec.run('id', 'id2'); //starts the group id and id2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment