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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:53:15+00:00 2026-06-04T03:53:15+00:00

I have a jquery app with multiple data-roles=page in one html file. Is it

  • 0

I have a jquery app with multiple data-roles=”page” in one html file.

Is it better to Bind all my buttons at first? Or bind the buttons that are on a certain “page” on pagecreate event?

Any benefits of doing one over the other?

ex:

<script>
    $(document).delegate("#page1",'pagecreate', loadedFirstPage);
    $(document).delegate("#page2",'pagecreate', loadedSecondPage);

     function loadedFirstPage(){
         $('#link1').bind('tap',function(){
            console.log('Hello World');
         });

         //HERE?
         $('#link2').bind('tap',function(){
            console.log('Hello World Again');
         });
     }

     function loadedSecondPage(){
         //OR HERE?
         $('#link2').bind('tap',function(){
            console.log('Hello World Again');
         });
     }
</script>

<div id="page1" data-role="page">
   <a href="#page2" id="link1">Click here</a>
</div>

<div id="page2" data-role="page">
   <a href="#page1" id="link2">Click here Again</a>
</div>
  • 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-04T03:53:18+00:00Added an answer on June 4, 2026 at 3:53 am

    The thing to take into consideration is that using .bind() iterates over the whole list of elements selected and runs the binding function on each element. So if you have a ton of elements (hundreds or more) then you probably only want to bind to the ones on the current page. However if you are dealing with a few elements, say less than 100, then you don’t need to go through the extra step of delegating your event bindings.

    If you bind to all the elements at once then you can run the code inside the document.ready event handler or simply place the JS code at the end of the HTML document so all the elements on the page are available when the JS runs.

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

Sidebar

Related Questions

I have a single page jQuery Mobile app with four data-role='pages' in place; so,
I have multiple html documents that share one css stylesheet (not multiple page div
I have a PhoneGap App using jQuery Mobile. At a certain page, I cannot
I have some simple jQuery that renders a page in my Rails app. Here's
I have my jquery mobile app pulling data from our mysql db using JSONP.
I have a very small jquery app with one button and a jquery function.
I have a legacy app that was built entirely in jQuery and HTML. Does
In my app I have jquery that is specific to each page, that is
I have a full Jquery Mobile app the currently builds and looks fine in
I have a jquery mobile web app. On my iPhone when I am 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.