Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Add namespace to placard events
Browse files Browse the repository at this point in the history
  • Loading branch information
interactivellama committed Jul 6, 2015
1 parent db432d6 commit 5bca4d0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion js/placard.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
this.$field.val(this.previousValue);
}

this.$element.trigger(action, obj);
this.$element.trigger(action + '.fu.placard', obj);
this.hide();
}
},
Expand Down
8 changes: 4 additions & 4 deletions test/placard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand All @@ -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);
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 5bca4d0

Please sign in to comment.