I am attempting to call up a jquery function on link click with no success:
here is my html:
<a href="..." id="removeItem" checkID="12" >Delete</a>
<a href="..." id="removeItem" checkID="13" >Delete</a>
<a href="..." id="removeItem" checkID="14" >Delete</a>
$("#removeItem").click(function(checkID) {
return false;
var checkID = $(this).attr("checkID");
$("#removeDialog").dialog( {
buttons: {
"No" : function () {
$(this).dialog("destroy");
$('input#CheckName').focus();
},
"Yes": function () {
$.ajax({
url: "itemRemoveWS.html?id=checkID",
data: {
"action" : "remove",
"id" : checkID
},
success: function (data) {
$("#removeDialog").dialog("destroy");
var ang = '';
var obj = $.parseJSON(data);
$.each(obj, function() {
ang += '<table class="form"><tr><td width="45">' + this["CheckID"] + '</td><td width="140">' + this["Name"] + '</td><td width="95">' + this["CheckNumber"] + '</td><td align="right" width="70">$' + this["Amount"] + '</td><td width="220" style="padding-left: 15px;">' + this["Description"] +'</td><td><a href="#">Delete</a></td></tr></table>';
});
$('#container').html(ang);
$("input#Amount").val('');
$("input#CheckName").val('');
$("input#Check_Number").val('');
$("select#Company").val('MMS');
$("th#dept").hide();
$('input#CheckName').focus();
}
});
}
}
});
});
You have return false;
as first instruction in your click event callback function. This means you are doing nothing.
Put it at the very last line of your logic or better change it to e.preventDefault();
using
$("#removeItem").click(function(e) {...}
As a side note, $("#removeItem").click(function(checkID) {}
checkID will be an ref to triggered event here, not an element id attribute.
And again, ID attribute MUST be unique for each element on each html page.
To call of function on a link click use javascript:void(0) as your href, then add your function call to the onclick event of your link:
<a runat="server" id="myButton" href="javascript:void(0);" onclick="myFunction();" ></a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With