Tuesday, 20 August 2013

when binding two .on "click" functions, one overwrites the other

when binding two .on "click" functions, one overwrites the other

These two links, when clicked:
<a
href="/modals.cfm?action=record_payment&amp;script=%2Fmanager%5Fpro%2Ecfm%2Fleague%2F268%2Faction%2Fregistration%2Fcontent%5Faction%2Fmanagedues%2Ftabindex%2F3&amp;player_id=41363&amp;dues_id=199&amp;league=268&amp;f_division_id=1014&amp;price2pay=10"
class="btn btn-mini facebox ttLT btn-success" alt="Record Manual Payment
for ashley wilkes" data-hasqtip="329" oldtitle="">Record Payment</a>
<a
href="/manager_pro.cfm/league/268/action/registration/content_action/managedues/tabindex/3/m0dal_update/manageleague/submethod/manageusersdrop_members/player_id/40454"
class="btn btn-mini btn-danger" data-confirm="Are you sure you want to
drop this member?">Drop Player</a>
trigger these functions:
$(document).on("click", "a[data-confirm]", function(event){
var href = $(this).attr('href');
if (!$('#dataConfirmModal').length) {
$('body').append('<div id="dataConfirmModal" class="modal"
role="dialog" aria-labelledby="dataConfirmLabel"
aria-hidden="true"><div class="modal-header"><button type="button"
class="close" data-dismiss="modal"
aria-hidden="true">×</button><h3 id="dataConfirmLabel">Please
Confirm</h3></div><div class="modal-body"></div><div
class="modal-footer"><button class="btn btn-info"
data-dismiss="modal" aria-hidden="true">Cancel</button><a
class="btn btn-warning" id="dataConfirmOK">I wish to
continue</a></div></div>');
}
$('#dataConfirmModal').find('.modal-body').text($(this).attr('data-confirm'));
$('#dataConfirmOK').attr('href', href);
$('#dataConfirmModal').modal({show:true});
event.preventDefault();
});
$(document).on("click", ".facebox", function(event){
var $link = $(this);
if ($(".modal").dialog( "isOpen" )===true) {
event.preventDefault();
} else {
new BootstrapDialog({
title : '<h3>' + $link.attr('alt') + '</h3>',
content : $('<div>Loading...</div>').load($link.attr('href')),
buttons : [
{
label : 'Cancel',
onclick : function(dialog){dialog.close();}
}
]
}).open();
event.preventDefault();
}
});
Each of them work individually but as soon as I click one, the other opens
up the link to the full screen. Its as if one is overwriting or negating
the binding of the other.
Is there a way to prevent this from happening?

No comments:

Post a Comment