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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:31:27+00:00 2026-06-10T23:31:27+00:00

I have been happily using JQM for awhile now. However I recently started a

  • 0

I have been happily using JQM for awhile now. However I recently started a new project which required dynamically created pages to be pushed into the history with their content determined by url parameters. I am going to show you how I originally approached controllers with JQM and how I have tried to approach the router plugin.

This is how I used to write all my controllers for JQM:

myApp.foo.controller = (function($){

    "use strict";

    var $page;

    var init = function()
    {
        $page = $("#foo-page");
        applyBindings();
    };

    var applyBindings = function()
    {       
        // Page transition events
        $page.bind("pagebeforeshow", onPageBeforeShow);
    };

    var onPageBeforeShow = function()
    {

    };

     return  {
        init: init
     }

})(jQuery);

$("#foo-page").live("pageinit", function(e)
{
    myApp.foo.controller.init();
});

So I am now using the JQM recommended routing plugin. I am not using spine or backbone. And I dont want to get this wrong as its fundamental to the app. So I load all my controllers and then load my router.js file.

This gives me the behaviour i’m expecting:

    var router = new $.mobile.Router([
        {"#foo-page": {events:"i", handler: myApp.foo.controller.init}},
        {"#foo-page": {events:"s", handler: myApp.foo.controller.onPageShow}},          

        {"#dynamic-foo(?:[?/](.*))?": {events:"i", handler: myApp.dynamicFoo.controller.init}},
        {"#dynamic-foo(?:[?/](.*))?": {events:"bs", handler: myApp.dynamicFoo.controller.onPageBeforeShow}},
    ]);

But Is this the right way to use the router plugin? Because I read the documentation and the author seems to use the router object as the actual controller.

To be clear, this works for me I’m just not sure if this is really the idea of routing or perhaps this is the wrong approach?

  • 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-10T23:31:28+00:00Added an answer on June 10, 2026 at 11:31 pm

    don’t worry, there’s no “right way” to use the router, and your approach is correct.

    Another way to do the same thing would be:

    var router = new $.mobile.Router([
        {"#foo-page": {events:"i", handler: "init"}},
        etc
    ],myApp.foo.controller);
    

    it’s just a matter of taste.

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

Sidebar

Related Questions

I have been happily using HgSubversion for awhile and today I forgot to add
I've been very happily using PredicateBuilder but until now have only used it for
I have an existing database, which I have been happily accessing using LINQtoSQL. Armed
I've been using MySQL happily for many years but have now come across an
We have been happily using the ASPExpert Menu control at work. Recently I have
I came across this recently, up until now I have been happily overriding the
I have recently started work on a project that has already been running for
I have been happily using VS 2010 for several weeks without any performance problems.
I have been happily developing my application locally and using sqlite3 as database only
I have been using eclipse indigo happily for android development for a while. In

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.