Reputation: 189
I'm trying to get a confirm dialog to work, but I already have a class attribute in my URL:
<a href="deleteMe.php?key=<?php echo $key; ?> class="load-external" data-target="#right_section">Delete Me</a>
I found this sample below, and when I use Class "confirmation" it works in my link above, but I need to use "load-external" as it is loading the content (deleteMe.php) back into the same DIV, not into an entirely new page.
<a href="deleteMe.php?key=22" class="confirmation">Link</a>
<script type="text/javascript">
$('.confirmation').on('click', function () {
return confirm('Are you sure you want to Delete this record?');
});
</script>
Is there any way to do this inline, or any other way so it does not conflict with the class="load-external" I must have in my href link ??
Thanks
Upvotes: 1
Views: 98
Reputation: 28196
simply write:
<a href="deleteMe.php?key=<?php echo $key; ?>"
class="confirmation load-external"
data-target="#right_section">Delete Me</a>
You can assign as many classes as you like within the class
attribute string. Separate them with a blank.
Upvotes: 1
Reputation: 6588
You can have many classes as you want. Example:
<a href="deleteMe.php?key=22" class="confirmation load-external">Link</a>
And also you can select many elements as you want, so can be:
$('.confirmation, .load-external').on('click', function () {
return confirm('Are you sure you want to Delete this record?');
});
Upvotes: 1