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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:12:43+00:00 2026-06-05T22:12:43+00:00

I get the feeling I’m missing something obvious, but I’m new to all of

  • 0

I get the feeling I’m missing something obvious, but I’m new to all of this, so please forgive a cry for help!

How exactly should I call a jQuery function of my own stored in a separate .js file? I’ve developed a working prototype of my app but am now trying to tidy up the code, and move various jQuery functions into a separate file where I can access them on each page. But for some reason I’m finding it impossible to access the code once I’ve turned it into a named function, either in the head of my html document or in the separate .js file. Crucially, I can’t find a simple reference to the correct syntax for actually calling the function!

Anyway, here’s the relevant bits of code:

<head>

<link rel="stylesheet" href="jquery.mobilecus-1.1.0.min.css"/>
<script type="text/javascript" charset="utf-8" src="cordova-1.8.1.js"></script>
<script src="js/jquery-1.7.2.js"></script>
<script src="js/jquery.mobile-1.1.0.min.js"></script>
<script src="js/myjquery.js"></script>

</head>
<body onload="onBodyLoad()">

<div data-role="page" id="page1" class="page">

    <script type="text/javascript">
        $(document).ready(function () {
        alert("alert1!");
        $(InitRightBar());   /// This is the problem!
        });
        </script>
...
</div>
...
</body>

And the entirety of the separate “myjquery.js” file:

$(function() { //ready

function InitRightBar (){
alert("alert2!");
$("#rightbar").live("swipeleft", function(){
                  $.mobile.changePage($("#page2"))
            });
}

}); //end ready

NB: Alert 1 is always firing, but Alert 2 never fires, even if I put it the function in the html head. I’ve tried multiple different syntaxes instead of “$(InitRightBar());

  • 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-05T22:12:45+00:00Added an answer on June 5, 2026 at 10:12 pm

    From you JS File , keep only these lines

       function InitRightBar (){
          alert("alert2!");
           $("#rightbar").live("swipeleft", function(){
                  $.mobile.changePage($("#page2"))
            });
        } 
    

    and remove the First and the last line.Also change the following

       $(InitRightBar());   /// This is the problem!
    

    to

       InitRightBar();
    

    only.

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

Sidebar

Related Questions

I get the feeling this is probably something I should know but I can't
I feel like this deserves a good comment but I get the feeling that
I've never seen this done, but i get a feeling that there's gotta be
I get the feeling that this is impossible, but is there a way to
I get the impression mootools will do this, but in a roundabout way. I
I get the feeling that the answer might be a duplicate of this: Jackson
After researching various hosts, I still get the feeling that it is somewhat impossible
I wish to get a quick feeling for how much copy and paste coding
I get the feeling almost everybody uses an editor (Vim, Notepad++, etc.) for the
I get the feeling I am still using asp type scripting techniques in the

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.