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

  • Home
  • SEARCH
  • 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 7972491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:52:51+00:00 2026-06-04T07:52:51+00:00

I have a fairly standard star voting functionality in my app that uses jQuery’s

  • 0

I have a fairly standard star voting functionality in my app that uses jQuery’s hover event. The partial that the star voting logic is in used to be rendered with the rest of the page once the DOM was initially loaded (HTML request). However, I would like to move the partial so that it’s not loaded with the page but can be loaded when the user wants. I made a typical AJAX request to load the partial but when it gets rendered the stars don’t react properly to events like a mouseover. Is this issue being brought on because I’m rendering the forms via AJAX or is there just a bug in my code? Thanks for the help

Update: Got it working using the on handler, thanks for the help all!

  • 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-06-04T07:52:53+00:00Added an answer on June 4, 2026 at 7:52 am

    You are likely trying to bind events to nodes that don’t exist in the DOM yet. The best way to solve this is to bind to a listener that exists prior to the Ajax request, that is an ancestor (sometimes incorrectly called “parent”, which is only one level of ancestor) of the content being fetched. For example, given this markup in the page itself:

    <div id="ajaxContainer">
      <!-- content will be periodically replaced with Ajax -->
    </div>
    

    “ajaxContainer” is an ancestor of whatever you’re going to fetch. Then you need to bind a listener using an appropriate method. In the old days you could use live() but it’s deprecated and was not so efficient anyhow. Then the recommendation was for delegate(), which solved efficiency problems. Now it’s for a delegated listener syntax of on(), which is roughly the same performance as delegate() but with different syntax.

    All that to say, use .on() if you are using jQuery 1.7+.

    Imagine your Ajax function retrieves a portion of a page containing your star system mouseover, which is inside a series of divs classed as “stars”. The syntax might look like:

    $(document).ready(function() {
      $('#ajaxContainer').on('mouseenter', '.stars', function() {
        $this = $(this); // cache this specific instance of a stars div as a jQuery object
        // do stuff with $this
      });
    });
    

    This says “Start listening inside ajaxContainer for events that match ‘mouse enters stars divs’ and when that happens, do stuff.”

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

Sidebar

Related Questions

I have a fairly standard OLTP normalised database and I have realised that I
In my Rails app I have a fairly standard has_many relationship between two entities.
I have a fairly standard blog app with the usual post and comments controller/models
I have a fairly standard mod_rewrite that comes packaged with a CMS called Modx
I've noticed that apps like instagram and picplz have a fairly standard screen that
I have a master project that's using a fairly standard source tree approach +
I have a question about forms. I have a fairly standard form that saves
I have a fairly standard rails app and would like to be able to
I have a fairly standard ASP.NET GridView that displays 2 columns that have a
I have a fairly standard MVC2 app running on 4.0 and under IIS6. I

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.