Reputation: 9378
for some reason only the asp.net hyperlink is not workin with jquery. Any suggestions?
<asp:HyperLink runat="server" ID="hypeDeleteBaseline" Text="Delete Baseline" /> <br/>
//Delete Baseline information
jQuery('[id$="hypeDeleteBaseline"]').click(function (e) {
e.preventDefault();
var equipid = "<%=Equipment.ID%>";
var inspectionid = jQuery('[id$="ddInspectionDate"]').val();
deleteBaseline(equipid, inspectionid);
});
Thanks for any help.
Upvotes: 0
Views: 1682
Reputation: 9378
Nothing was wrong with my code. The asp hyperlink was being loaded via jquery.load ajax call. so on the call back function for load i just added
jQuery('[id$="hypeDeleteBaseline"]').click(function (e) {
e.preventDefault();
var equipid = "<%=Equipment.ID%>";
var inspectionid = jQuery('[id$="ddInspectionDate"]').val();
deleteBaseline(equipid, inspectionid);
});
And now it works perfectly. Thanks for all suggestions.
Upvotes: 0
Reputation: 156459
Your selector is a little unusual. Have you tried:
jQuery('#hypeDeleteBaseline').click(...)
Also, have you checked the HTML that gets rendered? As often as not, the ID that you set on the control is not actually the ID that gets rendered in the HTML. Something like this might work:
jQuery('<%=hypeDeleteBaseline.ClientId%>').click(...)
Finally, you didn't include much context with your javascript class. Make sure it's inside a document-ready handler:
<script type="text/javascript">
jQuery(function(){
//Delete Baseline information
//...
});
</script>
Upvotes: 1
Reputation: 66641
You need to get the ClientId as rendered on html and not as parametre, try:
jQuery('#<%=hypeDeleteBaseline.ClientID%>')
or if you working with Net 4, set ClientIDMode="Static"
on your HyperLink to not change the render id.
Upvotes: 0