I am trying to create a custom confirmation dialog when a user clicks a link to a specific class. This is pretty trivial, but to catch, if the user clicks the "Confirm" button in the dialog box (using Twitter Bootstrap 3), I want to call a click on the same link, but this time instead of showing the dialog, follow the link.
Everything is fine until the moment when I want to trigger the click event in the tag <a>with some parameters. Here is a very simplified example of what I want to achieve
Html:
<a class="initial" href="http://yell.com">click me</a>
<div class="dialog hidden">
<a href="#">Click me again</a>
</div>
JavaScript:
$(document).on('click', 'a.initial', function(e, forced){
if(typeof(forced) !== 'undefined' && forced === true){
$(this).addClass('clicked');
console.log('Clicked');
return true;
} else{
e.preventDefault();
$(this).removeClass('clicked');
$('div').removeClass('hidden');
}
});
$(document).on('click', 'div.dialog a', function(e){
$(this).parent().addClass('hidden');
$(this).parent().prev().trigger('click', [true]);
});
Here is the JSFiddle sample
, , console.log, URL-. , , . , window.location = $(element).attr('href'), , ?
.