Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- YUI().use('event', 'base', function(Y) {
- var Foo = function() {
- Foo.superclass.constructor.apply(this, arguments);
- };
- Y.extend(Foo, Y.Base, {
- }, {
- NAME: 'foo'
- });
- var Bar = function() {
- Bar.superclass.constructor.apply(this, arguments);
- };
- Y.extend(Bar, Y.Base, {
- _prevFn: function() {
- console.info('Bar::Event Prevented Function..');
- },
- _defFn: function() {
- console.info('Bar::Event Default Function..');
- },
- initializer: function() {
- this.publish('event', {
- defaultFn: this._defFn,
- preventedFn: this._prevFn,
- emitFacade: true,
- bubbles: true,
- prefix: 'bar'
- });
- }
- }, {
- NAME: 'bar'
- });
- var b = new Bar();
- b.on('bar:event', function(e) {
- console.info('Single Instance Prevented');
- e.preventDefault();
- });
- console.log('Single Instance Fire');
- b.fire('bar:event');
- var f = new Foo();
- var b1 = new Bar();
- b1.addTarget(f);
- f.on('bar:event', function(e) {
- console.info('Bubble Instance Prevented');
- e.preventDefault();
- });
- console.log('Bubbled Instance Fire');
- b1.fire('bar:event');
- });
Add Comment
Please, Sign In to add comment