I am building my first MVC application using "database first" approach, everything works fine, however, I'm stuck at the point of using jQuery to make the MVC tables editable (inline), every row has a link when I click on that
link, the scenario should be as follows:-
1-click on the link in a specific row
2-get this specific row editable
the problem is as follows :-
1-when I click on the link of a specific row
2-all rows become editable !!!
Here is the HTML code :-
<table id="my_table">
<tr>
<th>
@Html.DisplayNameFor(model => model.AFECode)
</th>
<th>
@Html.DisplayNameFor(model => model.Remarks)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr contenteditable="false">
<td contenteditable="false">
@Html.DisplayFor(modelItem => item.AFECode)
</td>
<td contenteditable="false">
@Html.DisplayFor(modelItem => item.Remarks)
</td>
<td contenteditable="false">
<a id="edit_link" href="#" onclick="edit()" >edit</a>
}
</table>
Here is the Jquery code including edit()
function:-
function edit() {
$("#my_table td").attr("ContentEditable") == "false" ? $("#my_table td").attr("ContentEditable", "true") : $("#my_table td").attr("ContentEditable", "false")
}
Now , how can i only get the row that has the link i clicked on to be editable?
thanks in advance