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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:41:27+00:00 2026-05-23T09:41:27+00:00

I just want to clear where should the javascript for the ajax pages should

  • 0

I just want to clear where should the javascript for the ajax pages should be put in. For example in my page as soon as the page loads i am making an ajax request and retrievn 20 records each consisting of around 10 divs with some buttons and actions of their own.

Now for the ajax and client side js actions for the newly loaded elements the js has to be put inside the callback in the parent function for them to work properly but this is getting messy as i have around 15 actions for the newly loaded controls.

It is quiet easy to put all the code along with the returned ajax page.

THat is if this is what i return from the initial request

 <div id="something">
 <input type="button" id="btn1">
 <input type="button" id="btn2">
 <input type="button" id="btn3">
 </div>

If i embed the respective js jquery code for these elements along with the returned result its working fine.

 $("#btn1").click(blah)
 $("#btn2").click(blah)
 $("#btn3").click(blah)

Question is , is this ok to do it this way.

  • 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-23T09:41:27+00:00Added an answer on May 23, 2026 at 9:41 am

    Use the $.live() method to add event logic to items added later in the pages life-cycle.

    $(":button").live("click", function(){
      // This works on all buttons loaded asynchronously too
      alert( "You clicked button #" + $(this).index() );
    });
    

    Online Demo: http://jsbin.com/obapej/edit

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

Sidebar

Related Questions

I just want to read multiple lines in a file. For example in sample.txt
Here is an example of JavaScript template from Ben Nadel's demo single page long-lived
Just want to know if there other optional wrapper framework available that generate client
Just want to know how to read an attribute of a parent node from
I just want an ASP.NET DropDownList with no selected item. Setting SelectedIndex to -1
I just want a quick way (and preferably not using a while loop)of createing
I just want my apache to register some of my predefined environment so that
I just want a simple tool that will help me quickly write scripts/packages that
I just want to see what files were modded/added/deleted between 2 arbitrary revisions. How
I just want to enable or disable the button inside a ControlTemplate for a

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.