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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:19:48+00:00 2026-06-13T00:19:48+00:00

I have 2 pages that use the same template. The only thing different is

  • 0

I have 2 pages that use the same template. The only thing different is the data-role="content" is different. I am using $.mobile.changePage('page2.php'); but the all.js file that I have in my head is not binding to the elements loaded in page2.

The script tag for ‘all.js’ is in the head of both pages and from what I have read, only the data-role="page" is loaded from the second page. Which is fine because the .on() bind should be binding to the new elements, however it isn’t. If I specifically refresh page2.php then the all.js file works, however if I use changePage it will not.

Why aren’t the new elements pulled in from changePage binding to all.js .on() selector?

HTML for both pages

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <link rel="apple-touch-icon" href="apple-touch-icon.png">

    <title>Title</title>

    <link rel="stylesheet" href="css/themes/default/jquery.mobile.theme-1.2.0.min.css">
    <link rel="stylesheet" href="css/themes/default/jquery.mobile.structure-1.2.0.min.css">

    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.mobile-1.2.0.min.js"></script>
    <script type="text/javascript" src="js/jquery.validate.min.js"></script>
    <script type="text/javascript" src="js/pages/all.js"></script>
</head>

<body>
<div data-role="page" data-theme="d">
    <div data-id="head" data-role="header" data-position="fixed" data-theme="b">
        <h1>Name</h1>
        <a href="#" id="headingsActionButton" class="ui-btn-right headingsActionButton hidden" data-role="button" data-inline="true" data-icon="check">Save</a>

    </div>

    <div id="mainContent" data-role="content">
        {PageContent}
    </div>
    <div align="center" data-id="foot" data-role="footer" data-position="fixed" data-inset="false" data-theme="c">
        Powered by 
    </div>
</div>
</body>
</html>

all.js

$(function() {
    /**
     * Prevent the header and footer from hiding on a non element tap.
     */
    $("[data-role=header], [data-role=footer]").fixedtoolbar({ tapToggle: false });

    /**
     * Scroll to the top of the collapsible heading
     */
    $('.ui-collapsible-heading').on('click', function(e) {
        window.scrollTo(0, $(this).offset().top - $('[data-role=header]').height());
        $('.headingsActionButton').addClass('hidden');
        var attr = $(this).parent().attr('data-action-id');
        if (typeof attr !== 'undefined' && attr !== false) {
            if (!$(this).parent().hasClass('ui-collapsible-collapsed')) {
                console.log('expanded');
                $('.headingsActionButton').attr('data-action-id', $(this).parent().attr('data-action-id'));
                $('.headingsActionButton .ui-btn-text').text($(this).parent().attr('data-action-text'));
                $('.headingsActionButton').toggleClass('hidden');
            } else {
                console.log('collapsed');
            }
        }
    });


});
  • 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-13T00:19:49+00:00Added an answer on June 13, 2026 at 12:19 am

    .on is not a simple drop in to replace .live, you need to use the correct syntax.

    $(context).on(events,targetelements,eventhandler)
    

    For example,

    $('#someparentelement').on('click','.ui-collapsible-heading',function(){...});
    

    To directly match what .live was doing, use document in place of '#someparentelement'

    Update

    The root of the problem is the click event on .ui-collapsible-heading is being stopped by JQM, meaning it can’t bubble up to the document. That leaves the only way to handle the event is binding it directly on that element without delegation.

    With that in mind, you’ll need it to run on every page, so you need to remove $(function(){}) since it only runs on the first page and instead use $(document).on("pageinit",function(){})

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

Sidebar

Related Questions

I have a lot of web pages that use the same exact html structure.
I have defined CSS in MasterPage so that all pages can use the same
i have a variable $cartTotal in cart.php page i want to use that same
I have a few pages and want that they use one style. See in
I have a web page that I use to update a fairly complex data
I use ADO.NET Entity-Framework, I have a page that is data-bound to an entity
I have a page layout that I use in my SharePoint solution when I
I have a page with some very basic examples that use HTML/CSS/JavaScript. I'd like
I have a page that requires jQuery.tmpl, but I want to use native knockout
I have a webforms page that makes quite extensive use of AJAX. There are

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.