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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:47:50+00:00 2026-05-26T00:47:50+00:00

I have some jquery-scripts which I want to put into a plugin. In my

  • 0

I have some jquery-scripts which I want to put into a plugin.

In my current setup the code is executed at “mobileinit” with my custom.js file sitting between Jquery.js and Jquery Mobile.js files.

This is what I’m doing:

(function($ , window, undefined) {
$( window.document ).bind('mobileinit', function(){
          alert ("init");
 });     
})(jQuery,window);

I would like to make this into a plugin using the Jquery Widget factory as recommended by JQM-developers

Currently I’m stuck with the following:

(function( $, window, undefined ){
   $.widget( "myPlugin", $.mobile.widget, {
        options: { },
        _create: function() {$.fn.myPlugin = function() {       
          alert ("init");          
           };
   $( window.document ).bind('mobileinit', function(){ {
     myPlugin();
     });
})( jQuery, window );

which does not work… if I put the plugin.js before JQM.js “mobile isn’t defined”. If I put it afterwards, nothing happens.

My question:
How can make a widget which runs on mobileinit, that is before Jquery Mobile.js is running.

Thanks for help!

  • 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-05-26T00:47:50+00:00Added an answer on May 26, 2026 at 12:47 am

    Ok. Here is a roundup of possibilities – you can do either of the following:

    1. bind to JqueryMobile pagecreate event (see here):
      This fires after elements have been enhanced, but before the page is shown

    2. bind to JqueryMobile pageinit event (same link):
      This way you can make changes to the JQM widgets before they enhance elements on a page. This should be the equivalent to $(document).ready()

    However, if you want to change JQM core itself, you need to bind to earlier events.

    1. bind to JqueryMobile mobileinit event (same link):
      You can only override Jquery Mobile stuff set (itself set at mobileinit) by putting your plugin file BEFORE Jquery-Mobile.js. However this way you can no longer use the widget factory structure recommended by Jquery Mobile, because it requires Jquery-Mobile.js to run first.

    I’m currently checking to see if I can bind to DOMContentLoaded, too. Maybe this is another solution

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

Sidebar

Related Questions

I have some jQuery/JavaScript code that I want to run only when there is
I have some jquery code which I am trying to translate to YUI. I
I am trying to put some jquery UI code into an existing asp.net app,
I have some jQuery code. I have called an Ajax function file, file.php, that
I have some jquery code that is doing an ajax lookup and returning comma
I have some jQuery code that highlights a link when clicked, and changes the
I have some jQuery code that intercepts links clicked on a page: $(document).ready(function() {
I have some elements and I'm using some jQuery plugins. I want to see
I have some JQuery code that shows or hides a div. $(div#extraControls).show(); // OR
I have 3 banners in which I want to have some mouseenter and mouseleave

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.