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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:36:41+00:00 2026-05-25T02:36:41+00:00

I am using backbone.js (0.5.3) with JQueryMobile (1.0 beta 2). I know there are

  • 0

I am using backbone.js (0.5.3) with JQueryMobile (1.0 beta 2). I know there are routing conflicts when using those libraries together, and I would like to know if there is a solution to use them :

  • without hacking into the jquery mobile source code like described in Ben Nolan’s pots : http://bennolan.com/2010/11/23/backbone-and-jquery-mobile.html
  • and without using another router like jquerymobile-router (unless there is no other option…)

My problem is quite similar to the one described in this post : jquery-mobile backbone.js routing

When when i make a request, the backbone render code of the corresponding backbone view gets triggered before the new jquery page is fully loaded. I’m trying to render my html generated code in the $(".ui-page-active") DOM element to target the page that is generated by jQueryMobile (or the page that is “activated”) :

MyView = Backbone.View.extend({
  el: $(".ui-page-active")
  render: function(){
    console.log(el)
  }
});

But the el attribute is empty when the render method is called, because jquery mobile has not yet rendered the dom…

Thanks for any help !

Update

Addy Osmani seems to have the answer to my question 🙂 but it will be for the next part of his (great) tutorial :
http://msdn.microsoft.com/en-us/scriptjunkie/hh377172.aspx

  • 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-25T02:36:42+00:00Added an answer on May 25, 2026 at 2:36 am

    Ok the solution is to disable jQuery Mobile ajax loading feature and call the $.mobile.changePage method manually.

    HTML page :

        <script type="text/javascript" charset="utf-8" src="js/mobile/jquery.js"></script>
        <script type="text/javascript">
          $(document).bind("mobileinit", function(){
            $.mobile.ajaxEnabled = false;
            $.mobile.hashListeningEnabled = false;
          });
        </script>
        <script type="text/javascript" charset="utf-8" src="js/mobile/jquery-mobile.js"></script>
    

    Then whenever a new route is triggered, I first build my new “jQuery page canvas” in the Backbone View constructor, append it to the HTML document body and set my el view element to this new div :

    Backbone.View

        $("body").prepend("""
          <div id="my-id" data-role="page" class="cloudy-background-mobile">
            <div class="cloudy-header" data-role="header" data-position="fixed"></div>
            <div class="cloudy-content" data-role="content"></div>
          </div>
        """)
        this.el = $("#logs-view")
    

    And in the render method :

    // Build the content using undescore.js templating system
    this.el.find('.cloudy-content').html(this.template({logs : this.collection}));
    this.find('.cloudy-header').html(this.template_header({logbook: this.logbook}));
    
    // Change the page using jquery mobile and reapply jquery styles
    $.mobile.changePage(this.el, "slide", false, false);
    this.trigger( "pagecreate" );
    

    Works like a charm and without any unnecessary hacks 🙂


    Here is my full Backbone View if it can help anyone :

    class LogsView extends Backbone.View
      constructor: (options) ->
        super
        $("body").prepend("""
          <div id="logs-view" data-role="page" class="cloudy-background-mobile">
            <div class="cloudy-header" data-role="header" data-position="fixed"></div>
            <div class="cloudy-content" data-role="content"></div>
          </div>
        """)
        @el = $("#logs-view")
        @logbook = options.logbook
        @collection.bind 'reset', @render
    
        @template = _.template('''
          <ul data-role="listview" data-theme="c" data-inset="true">
            <% logs.each(function(log){ %>
              <li>
                <a href="#logs-<%= log.cid %>"><%= log.getLabel() %></a>
              </li>
            <% }); %>
          </ul>
        ''')
    
        @template_header = _.template('''
          <h1>Carnets <%= logbook.get('name') %></h1>
          <a href="#logbook-<%= logbook.cid %>-logs-new" data-icon="plus" class="ui-btn-right">&nbsp;</a>
        ''')
    
      render: =>
        # Build the content using undescore.js templating system
        @el.find('.cloudy-content').html(@template({logs : @collection}))
        @el.find('.cloudy-header').html(@template_header({logbook: @logbook}))
    
        # Change the page using jquery mobile and reapply jquery styles
        $.mobile.changePage(@el, "slide", false, false)
        @el.trigger( "pagecreate" )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am using backbone-rails in my Rails app. I would like to know
I'm using Backbone.js's routing . It generate urls for browsers like this: http://my-app.com/help For
Using Backbone I can fetch the Collection like below and render a Backbone View
Using backbone.js, is it possible to chain Url routes? if I have something like
Using Backbone.js I know it's highly recommended to set a model's property using the
New to using Backbone and have a very simple application. Basically there are Clients
I’m using Backbone.js and Rails. In Backbone.js I use HTML5 push state to set
I know it's possible to have get and post, but I'm using Backbone.js where
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a

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.