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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:36:04+00:00 2026-06-05T05:36:04+00:00

I have a multipage document but I’ve been displaying html and doing validation for

  • 0

I have a multipage document but I’ve been displaying html and doing validation for a single page within one php file:

<div id="checkPage" data-role="page">
  <div data-role="header">
    <h1>Page Title</h1>
  </div>
  <div data-role="content">
    <?php
    $form = $_REQUEST['form'];  //this is simply a hidden input in my form that I reference to know if a form submission has occurred
    if($form) {
      $res = process();
      if(is_array($res)) { //if the data is an array then it is an array of errors that I will display to the user
        $html = page($res); 
      } else {
        $html = $res;  //if the data is not an array then it is confirmation html that the request was successful.
      }
    } else {
      $html = page();
    }
    echo $html;
    ?>
  </div>
</div>

In my page() function I am appending some jquery after my HTML:

$detail .= chr(10) . '<script type="text/javascript">';
$detail .= chr(10) . '$( "#checkPage" ).bind( "pageinit",function(event){';
$detail .= chr(10) . '  $("#txtAmount").change(function(){';
$detail .= chr(10) . '    alert("INSIDE");';
$detail .= chr(10) . '  });';
$detail .= chr(10) . '});';
$detail .= chr(10) . '</script>';
return $detail;

I see the alert when I navigate to my page then type-in (and leave) the amount textbox. I also see the alert if I click the cancel button on the page (where I’m redirected to another page) then return again through menu hyperlinks and type-in (and leave) the textbox again. However, if I submit the form, discover validation errors and re-display the page, the pageinit is not set again. Even if I leave off the pageinit logic the change event no longer is set.

What am I doing wrong? I appreciate any help I can get.

  • 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-05T05:36:05+00:00Added an answer on June 5, 2026 at 5:36 am

    When you modify the DOM, you actually get a whole new set of elements. Events bound to elements that were replaced are gone, since the original DOM elements are no longer there. See the jQuery FAQ

    http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_AJAX_request.3F

    You can use jQuery.live to bind to elements that match now and in the future.

    http://api.jquery.com/live/

    Or, you can place your binding logic in a common function and call it after Ajax success, as outlined here

    http://jetlogs.org/2009/01/29/re-binding-jquery-events-on-ajax-callbacks/

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

Sidebar

Related Questions

I have an html document with multiple commented-out PHP arrays, e.g.: <!-- Array (
I have multiple html documents that share one css stylesheet (not multiple page div
I have multiple document.ready functions on a page and I want a function to
I have a multi-page document and I'm binding to the pageshow event of page
Is it bad to have multiple $(document).ready(function() {}); on your page? I have a
I know how to validate a single checkbox, but what if I have multiple
I have a HTML document that I want to remove specific tags from, identified
I have a site with multiple document libraries in it. One of the site
I have multiple paragraphs of text in an HTML document. Also, at various points,
Hi I have been trying to make a show/hide toggle button with jquery but

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.