Really could use some help / logic.
I want to pass an elementid on the href of a jquery impromptu that can then be used to append to a destination url.
That is; start with a href:
<a class="link" href="javascript:;" elementid="66">Remove item</a>
I want it so that if I click on this link it will send me to: remove-element.php?elementid=66
My javascript looks like:
<script>
function removeItem(id) {
var txt = 'Are you sure you want to remove this item?';
$.prompt(txt, {
buttons: {Yes: true, Cancel: false},
callback: function(accept) {
if (accept) {
window.location = "remove-element.php?elementid=x";
}
return false;
}
});
}
$('a.link').click(function() {
removeItem($(this).data('id'));
return false;
});
</script>
in order to use $(this).data('id')
, you need to set your anchor tag as:
<a class="link" href="javascript:;" data-elementid="66">Remove item</a>
and pass in the value, as:
$('a.link').click(function() {
removeItem($(this).data('id'));
return false;
});
function removeItem(id) {
var txt = 'Are you sure you want to remove this item?';
$.prompt(txt, {
buttons: {Yes: true, Cancel: false},
callback: function(accept) {
if (accept) {
window.location.href = "http://your_site.com/remove-element.php?elementid=" + id;
}
return false;
}
});
}