From 5bca4d06b1ca386c380e23a4cd760fc7a6d44255 Mon Sep 17 00:00:00 2001 From: Stephen James Date: Mon, 6 Jul 2015 10:57:36 -0400 Subject: [PATCH] Add namespace to placard events --- index.js | 7 +++++++ js/placard.js | 2 +- test/placard-test.js | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index a6e27d03f..594096b6f 100644 --- a/index.js +++ b/index.js @@ -440,6 +440,13 @@ define(function (require) { }); }); + $('#myPlacard3').on('accept.fu.placard', function() { + console.log('accept.fu.placard'); + }); + + $('#myPlacard3').on('cancel.fu.placard', function() { + console.log('cancel.fu.placard'); + }); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RADIO diff --git a/js/placard.js b/js/placard.js index da510ce0e..c2e2d6f00 100644 --- a/js/placard.js +++ b/js/placard.js @@ -76,7 +76,7 @@ this.$field.val(this.previousValue); } - this.$element.trigger(action, obj); + this.$element.trigger(action + '.fu.placard', obj); this.hide(); } }, diff --git a/test/placard-test.js b/test/placard-test.js index 825fb2f3e..1e8e3df66 100644 --- a/test/placard-test.js +++ b/test/placard-test.js @@ -27,7 +27,7 @@ define(function(require){ $('body').append($placard); $placard.placard(); - $placard.on('cancel', function(e, helpers){ + $placard.on('cancel.fu.placard', function(e, helpers){ ok(1===1, 'default action event (cancel) triggered upon external click'); }); @@ -43,7 +43,7 @@ define(function(require){ var $placard = $(html).find('#placard2'); $placard.placard(); - $placard.on('cancel', function(e, helpers){ + $placard.on('cancel.fu.placard', function(e, helpers){ ok(1===1, 'default action event (cancel) triggered upon external click'); }); $('body').append($placard); @@ -71,13 +71,13 @@ define(function(require){ var $placard = $(html).find('#placard1'); $placard.placard(); - $placard.on('accept', function(e, helpers){ + $placard.on('accept.fu.placard', function(e, helpers){ ok(1===1, 'accept event triggers on accept'); equal(typeof e, 'object', 'event object passed in accept event'); equal(typeof helpers, 'object', 'helpers object passed in accept event'); equal((helpers.previousValue!==undefined && helpers.value!==undefined), true, 'helpers object contains correct attributes'); }); - $placard.on('cancel', function(e, helpers){ + $placard.on('cancel.fu.placard', function(e, helpers){ ok(1===1, 'cancel event triggers on cancel'); equal(typeof e, 'object', 'event object passed in cancel event'); equal(typeof helpers, 'object', 'helpers object passed in cancel event');