I have a jQuery function that I'm having a minor problem with:
$(function() {
$("a.CompletedCheckBox").click(function() {
if($(this).hasClass("CheckedCompletedCheckBox")) {
$(this).removeClass("CheckedCompletedCheckBox");
} else {
$(this).addClass("CheckedCompletedCheckBox");
}
$.get("/Tasks/Complete/" + this.id, "", function() {});
});
});
The first time I click the link, the event function works as expected. However each subsequent time I click the link, the class toggles correctly, however the $.get request does not fire.
Any idea why the request to the server only fires the first time?
EDIT: Here is the markup that I am using:
<table>
<tr>
<th>
Header Text
</th>
... and so on ...
</tr>
<% foreach (var item in Model as Item[])
{%>
<tr>
<td>
<a href="#"
class='<%= "CompletedCheckBox " + (item.Complete ? "CheckedCompletedCheckBox" : "") %>'
id='<%= item.ID %>'></a>
</td>
... and so on ...
</tr>
<% } %>
</table>
EDIT 2: This works fine in FireFox, but not IE7. I would like to support IE in my app, so I need to come up with why this isn't working for IE.
I'm loading jQuery from Google (http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js), if it make any difference.