Reputation: 219
I have a simple button on a popup implemented in my webpage with data-rel="back"
I need to get an alert when the back button (dat-rel="back") is clicked. Is there a way to determine this? I tried to add to every class selector a click event but it wont work.
$(document).ready(function() {
$(".ui-icon-left").click(function() {
alert("clicked");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" data-rel="back" class="ui-icon-left ui-btn ui-corner-all ui-shadow ui-btn ui-icon-back ui-btn-icon-notext ui-btn-left">Click</a>
Upvotes: 0
Views: 516
Reputation: 7697
This is a possible answer to your current question:
$(document).on("vclick", "[data-rel=back]", function(e) {
console.log("Clicked!!!");
});
Don't know what you are tring to do, but, as Omar correctly pointed out in a previous comment, you can't prevent this way a popup
from closing.
If you have a popup
with mandatory fields, maybe you can remove the data-rel="back"
link, add data-history="false"
and data-dismissible="false"
to your popup
markup and create your own close button where you can execute the necessary tests and close the popup
manually.
Upvotes: 1