Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7492935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:40:11+00:00 2026-05-29T16:40:11+00:00

Before I added loadItems function, $(.ActivateItem).click(function () {…}): works fine. But when I made

  • 0

Before I added loadItems function, $(".ActivateItem").click(function () {...}): works fine. But when I made jquery code to load items on a table, class name (for I think) is not recognized.

<script type="text/javascript">
    $(document).ready(function () {
        loadItems(5);
        function loadItems(rc) {
            $.ajax({
                type: "GET",
                url: '@Url.Content("~/User/UserList")',
                data: { take: rc },
                dataType: 'json',
                success: function (response) {
                    var tags = "<tr><th>Login id</th><th>First name</th><th>Middle name</th><th>Last name</th><th>Prefix</th><th>Suffix</th><th>Reset</th><th>Email</th><th></th></tr>";
                    $.each(response, function (index, item) {
                        tags += "<tr id=" + item.UserID + ">" +
                                    "<td>" + item.LoginID + "</td>" +
                                    "<td>" + item.FirstName + "</td>" +
                                    "<td>" + item.MiddleName + "</td>" +
                                    "<td>" + item.LastName + "</td>" +
                                    "<td>" + item.Prefix + "</td>" +
                                    "<td>" + item.Suffix + "</td>" +
                                    "<td>" + item.IsReset + "</td>" +
                                    "<td>" + item.SendEmail + "</td>" +
                                    "<td>" +
                                    "<a href=# class='ActivateItem' data-id = " + item.UserID + " item-data = " + item.LoginID + ">Activate</a> | " +
                                    "<a href=/BaseAdmin/User/Details/" + item.UserID + ">Details</a></td></tr>";
                        alert("<a href=# class='ActivateItem' data-id = " + item.UserID + " item-data = " + item.LoginID + ">Activate</a> | ");
                    });
                    $("#table-list").html(tags);
                }
            });
        };

        $(".ActivateItem").click(function () {
            var id = $(this).attr("data-id");
            var display = $(this).attr("item-data");
            alert("Hello");
            var answer = confirm("Activate user with login id: " + display);
            if (answer) {
                $.post("/User/Activate", { "id": id },
                    function (data) {
                        if (data > 0) {
                            $("#row-" + data).fadeOut('fast');
                        } else {
                            alert("Data was not deleted successfully.");
                        }
                    });
            }
        });

        $("#rows-count").keypress(function (e) {
            if (e.keyCode == 13) {
                var rowscount = $(this).val();
                loadItems(rowscount);
            }
        });
    });
</script>  

<table id="table-list"></table>
<div id="pager">
    Rows: <input type="text" id="rows-count" />
    <input type="button" id="btn-next" value="Next"/>
    <input type="button" id="btn-back" value="Back" />
</div>  

The $(“.ActivateItem”) is not working, what did I missed?
Hope someone could help, or if you have better solution, please share. Thanks!

By the way, this was the old code where $(".ActivateItem") works fine:

<table id="table-list">
    <tr>
        <th>
            Login id
        </th>
        <th>
            First name
        </th>
        <th>
            Middle name
        </th>
        <th>
            Last name
        </th>
        <th>
            Prefix
        </th>
        <th>
            Suffix
        </th>
        <th>
            Reset
        </th>
        <th>
            Email
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr id="row-@item.UserID">
            <td>
                @Html.DisplayFor(modelItem => item.LoginID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FirstName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.MiddleName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.LastName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Prefix)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Suffix)
            </td>
            <td>
                @if (item.IsReset)
                { <text>YES</text>;
                }
                else
                { <text>NO</text>;
                }
            </td>
            <td>
                @if (item.SendEmail)
                { <text>YES</text>;
                }
                else
                { <text>NO</text>;
                }
            </td>
            <td>
                <a href="#" class="ActivateItem" data-id = "@item.UserID" item-data = "@item.LoginID">Activate</a> |
                @Html.ActionLink("Details", "Details", new { id = item.UserID })
            </td>
        </tr>
    }
</table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:40:13+00:00Added an answer on May 29, 2026 at 4:40 pm

    For elements loaded with AJAX (after the page has completed loaded), you need to use the method live: http://api.jquery.com/live/

    So you should change:

    $(".ActivateItem").click(function(){...})
    

    to

    $(".ActivateItem").live('click', function(){...});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm adding a bg to the same canvas, but it's overlapping everything added before
I have userscript. I recentyly added jquery to it. Before I added jquery that
I have a 2 jQuery scripts- one before I added .preventDefault, and a copy
In order to clean up some bad data I added a before save callback.
Before I added dataType: jsonp my autocomplete was working. Now I need to make
Before I added my ListView, along with changing my TableLayout height to wrap_content as
I have a large Javascript codebase to convert to jQuery. The code is structured
I have this code I'm working on and when I added the fieldset to
Here's a pastebin link to my entire jQuery code. [ http://pastebin.com/w57ma5Gx ] The Thumbnails
Before I added a button to the layout XML for my rows, the row

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.