Diego_DX
Diego_DX

Reputation: 1071

how can I Highlight Ajax.ActionLink when is selected

So how can I Highlight when the client clicks Ajax.ActionLink I have a class in CSS that works with @Html.ActionLink but for

 @Ajax.ActionLink("select", "Index", "Certificacion",
                      new { id = item.CertificacionId },
                      new AjaxOptions
                      {
                          HttpMethod = "GET",
                          UpdateTargetId = "linkEdit",
                          InsertionMode = InsertionMode.Replace
                      },
         new { @class = "selectedRow" })|

so how can make that the client know was the selected

Upvotes: 1

Views: 2935

Answers (1)

user596075
user596075

Reputation:

This could be done with JavaScript. Here's an example using jQuery:

@Ajax.ActionLink("select", "Index", "Certificacion", 
                      new { id = item.CertificacionId }, 
                      new AjaxOptions 
                      { 
                          HttpMethod = "GET", 
                          UpdateTargetId = "linkEdit", 
                          InsertionMode = InsertionMode.Replace 
                      }, 
         new { @class = "selectedRow", id = "YourActionLink" })
@* Notice the added html attribute property *@

Then your jQuery code could be like this:

$(document).ready(function() {
    $('#YourActionLink').click(function()
        {
            $(this).addClass('YourSelectedItemClass');
        });
});

And then just some extremely simplified CSS just to complete this example:

.YourSelectedItemClass
{
    background-color: yellow;
}


jQuery Working Example

Please see this working jQuery jsFiddle to prove that the jQuery is correct.

Upvotes: 3

Related Questions