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 6186033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:49:04+00:00 2026-05-24T01:49:04+00:00

I have a simple webpage that uses the jquery template plugin to dynamically load

  • 0

I have a simple webpage that uses the jquery template plugin to dynamically load data into a table using a json call on page load. In that table, I want to put buttons/div or anything clickable that I can then put a function on that will open a new page to edit the contents of that column.

The problem is that none of the jquery stuff works in the buttons that I put in the table. If i put the same button out of the table (i.e. do not dynamically generate it) then it works fine but then I dont get one button per column.

Here is what i have on the page load

$(document).ready(function() {
    $.ajax({
        type: 'POST',
        dataType: "json",
        url: "http://server:8000/categories/list",
        success: function (data) {
                LoadCategories(data['CategoryList']);
        }
    });

    $(".editButton").button(); // using jquery-ui
    $(".editButton").click( function() {
        alert("Button has been clicked");
    });
});

and my template looks like

   <script id="catTemplate" type="text/x-jquery-tmpl">  
        <tr id="$CategoryId">  
            <td> <button id="edit-${CategoryId}" class="editButton"> Edit</button> </td>
            <td> ${CategoryName}</td>
            <td> ${OtherValue} </td>
        </tr>  
    </script>  

The table loads properly and everything, its just that the jquery stuff is not applied to the dynamically generated stuff. Why is that and how can I get the buttons to do what I want?

  • 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-24T01:49:05+00:00Added an answer on May 24, 2026 at 1:49 am

    Your jquery to add the click handler is likely running before the content is actually in the page. Remember, the Ajax call is asynchronous so your ajax call is just the START of the ajax call. It does not complete until the success function.

    I would suggest putting any modifications of the ajax loaded content in the success handler after you’ve actually added the content to the page.

    You can also use:

    $(".editButton").live('click', function() {
        alert("Button has been clicked");
    });
    

    as the live handler will catch all clicks at the document level and then check to see if you’ve added click handlers for them there (so it will work even if you specify it before the element is added to the page), but that is somewhat less efficient than operating directly on the objects AFTER they’ve been added to the page in your success handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple accordion in my webpage that I initialise with :
Pretty simple question, I have a webpage that is used exclusively on iPads. I've
I have a simple webpage that adds & deletes options from a select element
I have a page that uses jQuery tabs to tabify a set of HTML
We have an asp.net webpage that uses viewstate. During a lengthy operation (that takes
I have a project that I'm working that uses XSLT to display data from
I have a simple web page that till now didn't need any login. It
Ok, i have simple scenario: have two pages: login and welcome pages. im using
Should simple JavaBeans that have only simple getters and setters be unit tested?? What
I have a simple webform that will allow unauthenticated users to input their information,

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.