I have a jquery function, that activates only when a table row is clicked and if so, it invokes controller method. However, this row also contains checkbox, and if i click it i don't want this method to be called. I tried checking the clicked element type or other parameters like class, but it seems to only apply to the entire row. Any ideas how to make it work?
JQuery:
function AllowTableRowsToBeClicked() {
$('#pref-table tbody tr').click(function () {
var resourceName = $(this).attr('title');
var categoryName = $('#pref-table').attr('name');
var url = "/Home/GetSpecific";
$.post(url, { categoryName: categoryName, resourceName: myClass }, function (data) {
});
});
}
cshtml:
<table class="table table-striped table-hover margin-top-20 pref-table" id="pref-table" [email protected]>
@for (int i = 0; i < Model.BiData.Count; i++)
{
<tr [email protected][i].Name name=@i title="@Model.BiData[i].Name" class="tableRow">
@Html.Hidden("resourceList[" + i + "]", Model.BiData[i].Name)
<th>
@Html.CheckBox("checkBoxList[" + i + "]", Model.BiData[i].Selected, new { @class = "resourceCheckbox" })
</th>
<th>
@Model.BiData[i].Name
</th>
</tr>
}
</table>