0

Im trying to call this script once the ajax link is clicked but for some reason it won't call #myLink.

@Html.ActionLink(" ", "DeleteRecord", new { id = item.JPAppId }, new { @class = "fa fa-trash", id = "myLink" })


<script type="text/javascript">
$("#myLink").click(function (event) {
    console.log("Method called");
});            

Bkwiat
  • 25
  • 6
  • 4
    You're not included `event.preventDefault()` before calling `console.log` - the default behavior is using `href` attribute to redirect into specified URL. – Tetsuya Yamamoto Nov 09 '18 at 04:23
  • you have 2 id? id = item.JPAppId and id = "myLink" read. https://stackoverflow.com/questions/16936132/can-a-html-element-have-multiple-unique-id-attributes/16936265 – Julius Limson Nov 09 '18 at 04:41
  • @YuukkaLimson The `{ id = item.JPAppId }` is used for `routeValues`, and the latter is used for `htmlAttributes`, so that the URL will look as `DeleteRecord?id=[someidvalue]` or `DeleteRecord/[someidvalue]`. – Tetsuya Yamamoto Nov 09 '18 at 04:46
  • @TetsuyaYamamoto not sure about the overloads but can the op post the rendered html also? – Julius Limson Nov 09 '18 at 04:50

0 Answers0