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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:45:24+00:00 2026-05-27T03:45:24+00:00

After much research, I have learned that binding the scroll event to the $(window)

  • 0

After much research, I have learned that binding the scroll event to the $(window) in the live state is not supported. This is fine, but I do have a question or two in regards to the script I am working on.

I have a website that is utilizing the HTML5 jQuery History Plugin (http://tkyk.github.com/jquery-history-plugin/) to load in pages for a fluid user experience since my site has an anchored audio player within it.

On one of my pages I have created an infinite scroll to load in Albums upon the window scroll. It works fine if you go to the page directly, but if you go there via an HTML5 enabled link (I have some links that are specifically for the HTML5 implementation) it doesn’t work.

Here is my Infinite Scroll Code:

jQuery(function() {
                var getMoreMedias, loading, mediaType, nearBottomofPage, page, pendingCall, genreType, url, did_scroll;
              page = 1;
              loading = false;
                // did_scroll = false
              mediaType = $('.breadcrumbs strong').attr('rel');
                genreType = $('.breadcrumbs strong').data('genre-id')

              nearBottomofPage = function() {
                return $(window).scrollTop() > $(document).height() - $(window).height() - $('#footer').height();
              };

              getMoreMedias = function(page, mediaType) {
                    opts = {
                     lines: 12, //The number of lines to draw
                     length: 7, //The length of each line
                     width: 3, //The line thickness
                     radius: 10, //The radius of the inner circle
                     color: '#000', // #rgb or #rrggbb
                     speed: 1, //Rounds per second
                     trail: 60, // Afterglow percentage
                     shadow: true //Whether to render a shadow
                    };

                    var spinner = new Spinner(opts).spin()

                    $('#loadingMore').append(spinner.el)

                    url = '/top_medias/'
                    url += mediaType

                    if(genreType)
                        url += '/' + genreType

                    url += '?page=' + page

                $.ajax({
                        cache: false,
                  url: url,
                  type: 'get',
                  dataType: 'script',
                  success: function(data) {
                    $('#loadingMore').html('');
                            loading = false
                  },
                        error: function() {
                            $('#loadingMore').html('<p>No more results could be found</p>')
                            loading = false
                        }
                });
              };

            $(window).scroll(function(){
                    did_scroll = true
            })

            setInterval(function(){
                if(did_scroll) {
                    if (loading) return;
                if (nearBottomofPage()) {
                      loading = true;
                      page++;
                        getMoreMedias(page, mediaType)
                        did_scroll = false
                }
                }
            }, 250)
        });

Is there any way to take what I have above and make it work if the page is accessed via Ajax (which is what the HTML5 plugin essentially does)?

  • 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-27T03:45:25+00:00Added an answer on May 27, 2026 at 3:45 am

    I’m not sure if this addresses your problem, but the statement that “it works when browsed but not when Ajax loads it” raised a flag to me – Javascript doesn’t execute in Ajax loaded pages, rather you must eval() evaluate the Javascript.

    What I do when I need this functionality is add a hidden <div> containing Javascript (without the `’ tag and execute that after loading, e.g. (psuedo code)

    $.ajax(url, success: function() { eval($('#ajax').html(); });
    
    <div id="ajax" style="display:none"> alert('here'); </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

after much debugging, I have determined that this code is ignoring the fast enumeration
After much research I am still stumped. I have a serial port object which
Not knowing the proper way, after much research on the web I found so
After much research and trial and error I found how to store the items
After much googling I have been wondering what the benefits/differences are between mysql and
After much fiddling, I've managed to install the right ODBC driver and have successfully
After loosing much sleep I still cannot figure this out: The code below (its
So I've decided after much debate and research to use symfony on my next
I come to ask for your aid after a lot of research on this
after some research I found that the best option for my current proyect is

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.