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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:33:06+00:00 2026-06-11T14:33:06+00:00

I am creating a jQuery Mobile web app, which loads some pages. For example,

  • 0

I am creating a jQuery Mobile web app, which loads some pages.

For example, a.html is my main page. It may call b1.html,b2.html,…,b100.html (User may click on one of buttons). (The pages are loading with ajax navigation feature of jQuery Mobile)

And there is some events in each b[i].html page, and ids and many things are same in every b[i].html page. But the point is, at any time, just one of them may be in DOM. So there will be no id conflicts or such.

The problem

The problem is the conflict of the events. When user come back to a.html from b[i].html, the HTML will be removed, but events will remain. This will cause many problems if I first go to b[i].html, and then come back to a.html and then go to b[j].html. I mean, b[j].html will not work correctly… 🙁

What I have tried

I have putted this in a.html, to remove all events:

$("#mainpage").off("pagebeforeshow").on("pagebeforeshow",function() {
    $("*").not("#mainpage").off();
    //Other initialization codes...
});

But, problem not solved…

(mainpage is the id of data-role="page" of a.html)

Example

For example, I have this in each b[i].html:

$(window).resize(function () {
    alert("Resized");
});

At the beginning (in a.html), If I resize the window, there will be no alerts, but after visiting b[i].html and then coming back to a.html, I’ll see alerts if I resize the window, even with that line of code (What I have tried part.)…


So, How to remove those event handlers when users come back to a.html from b[i].html?

  • 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-11T14:33:07+00:00Added an answer on June 11, 2026 at 2:33 pm

    If you are using jQuery Mobile, more than one of said pages may exist in the dom at the same time, resulting in non-unique id conflicts.

    I would ditch putting js on the individual pages and have it done from the primary page, or through a script loading system such as require.js. Then do all of the events through delegation from the document. Obviously that won’t work with window.resize(), but it doesn’t need to be delegated anyway.

    “Can you please explain more?”

    Basically, if you are including scripts on the child pages, you will need to have both setup and teardown for every page. setup adds the events, and teardown removes them. If you instead used a single global script that adds ALL of the events using event delegation from the document, all of the pages should work. Obviously that global script could get pretty big on a complex site, so you could instead use require.js to load in js that does the same thing as needed, preventing it from loading the same dependency more than once.

    As far as removing all events, I’ve never tried this, but can you use $("*").off()? According to the docs it should work. I’m not sure how it will affect jQuery mobile. To remove events on the document and/or window, you will have to do it manually because $("*") will not select them.

    $(document).on("vmousemove","#link",func) is how you delegate an event from the document.

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

Sidebar

Related Questions

I am creating a mobile singlepage web app using jquery mobile. The webapp includes
Creating app with jQuery Mobile, I want a page to load data from a
I'm creating pages for a small web-based game which must have some background music
I am creating one application with jquery.mobile-1.0a4.1 release. I have a page which is
I am creating a web app using jQuery Mobile and PhoneGap. There is a
I'm creating a web app with jQuery Mobile. My map doesn't show the way
I am creating an app using jQuery Mobile. I have a listview from which
When creating a jquery mobile / phonegap app, is it ok to pass variables
I am creating a jQuery Mobile page that has two select menu's, one is
I am creating a mobile app using jquery mobile, PHP using JSON for fetching

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.