c# - Passing action link value from partial view to view -
in view have section
<div id="assnamesection" style="display: none;"> <div id="assnamesectionload"></div> </div>
and there bit of jquery shows , opens partial view in section when check box ticked.
... $("#assnamesectionload").load(newurl);
this works. in sub section has been loaded row data action link , row id id.
i'm trying pass id of row click main view editing.
i figure out how use .click
capture action link in form/view/section.
is possible, can point in right direction please?
edit more info
action link code in partial view being rendered in assnamesectionload div
<td class="actionlinks"> @html.actionlink("link text", "actionname", new { controller = "mycontroller", id = item.id }, new { @class = "my-class" }) </td> </tr> } </table>
html section
<div id="assnamesection" style=""> <div id="assnamesectionload"> <input name="__requestverificationtoken" type="hidden" value="zt9mlom1zfuv_oaihoql_9at-ch2fvkrs2ohodr1wczkpmuhwlqhms8_rtsrrcscybflna7psrvlu1-xhxamc-jzhppx0ufbz3gvzn62tqajxtzpu4t_j3ntrxy2e6yh0"> <div> <div> <table class="table"> <tbody><tr> <th> relationship </th> <th> associated name </th> <th> options </th> </tr> <input id="txtassnamelineid" name="item.id" type="hidden" value="12157par121600"> <tr> <td> yyy </td> <td> xxx </td> <td class="actionlinks"> <a class="my-class" href="/mycontroller/actionname/12157par121600">link text</a> </td> </tr> </tbody></table> </div> </div> </div> </div>
jquery
<script> $("a.my-class", "#assnamesectionload").click(function (e) { e.preventdefault(); console.log("a my-class has been clicked"); }); </script>
as long have entrypoint jquery selector can use .click
function. let's there $('.clickable')
withing $("#assnamesectionload")
element (which might generate in partial view or whatever). can use $('.clickable', '#assnamesectionload').click(function(){...})
handle behaviour.
the basic concept jquery @ final html, not html within view you've put it.
edit:
to select id of input element, use jquery:
$("a.my-class", "#assnamesectionload").click(function (e) { e.preventdefault(); var id = $(this).parents('tr').prev('input').attr('id'); alert("a my-class has been clicked id="+id); });
here's jsfiddle code.
Comments
Post a Comment