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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:14:50+00:00 2026-05-27T14:14:50+00:00

Can I use exactly the same code to handle clicks for static and for

  • 0

Can I use exactly the same code to handle clicks for static and for Ajax-generated buttons? The reason I ask is that I can’t get a click handler to work for an Ajax button, but if I write the equivalent static HTML, the click does work.

This code is the static version, which does work:

// in JS file:
$(function(){
   $('input.sButton').click(function(){
      var f = $.farbtastic('#picker');
      f.linkTo(this);
      return false;
   });
});

In the “static HTML”:

<div id = "inputArea">
<label style="white-space: nowrap; line-height: 14px; height: 14px; vertical-align: bottom;">
<input id="sButton1" class="sButton" type="button" style="background-color: rgb(113, 16, 232);">
fubar1
</label>
</div>

The normal “dynamic HTML” looks like this:

<div id = "inputArea">
</div>

The Ajax code loads the buttons into ‘inputArea’. I derived the static version of this code from Firebug. I ran the Ajax routine, then got the HTML view in Firebug, which included the server output, and cut-and-pasted it exactly into my static test code, which is reproduced above. In other words, I know that the static and dynamic HTML are equivalent.

But – the static code works, and the dynamic one doesn’t. Firebug shows the JS click handler being entered for the static version, and the farbtastic colour picker pops up, but this doesn’t happen in the dynamic code. Any ideas?

  • 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-27T14:14:51+00:00Added an answer on May 27, 2026 at 2:14 pm
    $('input.sButton').live('click', function(){
          var f = $.farbtastic('#picker');
          f.linkTo(this);
          return false;
       });
    

    .live listens even for ajax content. Thsi should do the trick. Also, you may want to look into jquery .on() as well. Make sure you’re using the latest jquery.

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

Sidebar

Related Questions

how exactly I can use public methods (non-virtual) with NHibernate? I have this code:
How can I change Eclipse font to use the exactly the same fonts as
I know why I want to use private virtual functions, but how exactly can
You can use SelectFolder() to get a folder or GetOpenFolderitem(filter as string) to get
I can use VS08's MFC/ActiveX template to create a C++ ActiveX object that I
I'm attempting to eliminate the duplication accross two ASP.NET web projects that use exactly
I want to use sendBroadcast to broadcast an intent that can only be received
My question is exactly the same as the one listed here The reason I'm
I'm having trouble building a connection string that my VB6 program can use to
I've been struggling to find a jQuery alternative that does exactly the same as:

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.