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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:06:18+00:00 2026-05-18T02:06:18+00:00

I am trying to make next/previous page with ajax left/right arrows keys working (like

  • 0

I am trying to make next/previous page with ajax left/right arrows keys working (like on facebook). Everything is fine and works, but I also have form on my page and if user focus on that form I want to stop observing left/right key, because without that you can’t move with arrows in the form, you are getting next/previous image instead of movement in the form.

My actual code is here, the comment_name is id of the field, if I first click into the field then the observing of the keydown is stopped. But if I first press left/right key then clicking into form does not stop observing.

It seems to me like it can’t work with ajax-returned html…?

document.observe("dom:loaded", function() {

  document.observe('keydown', function(event){
    if(event.keyCode == Event.KEY_RIGHT) {
      if (Prototype.Browser.IE) {
        $('next').click();;
      }
      else {
        $('next').simulate('click');
      }
    }
  });

  $('comment_name').observe('focus', function(event){
   document.stopObserving('keydown');
  });

The page is here http://beta.sigut.net/photos/2027, the current code in javascripts/application.js

Thank you very much! maybe my approach is all wrong…

  • 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-18T02:06:19+00:00Added an answer on May 18, 2026 at 2:06 am

    You have to bind the observe every time new AJAX content is loaded.
    That means calling

      $('comment_name').observe('focus', function(event){
       document.stopObserving('keydown');
      });
    

    After adding the AJAX loaded html into the DOM.

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

Sidebar

Related Questions

I'm trying to make it so the next and previous page links do not
I am trying to make the next and previous button more defined. Are there
I am trying to make prev - next sliding between content on a page.
Im trying to make a basic while loop example im preperation for my next
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
Trying to make a small countdown timer in my app but it's not working.
I'm trying to use ajax to make multiple simultaneous requests to a php script,
I'm trying to make a PHP script to find the next occurence of a
I'm trying to make a comments-system on my site. I manage the ajax part
I'm trying to make a navigation system using document.onkeyup where pressing left arrow on

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.