Search code examples
jquery-mobilebackbone.jsdocument-ready

What's wrong with jquery document ready function working with jquery mobile?


enter image description here

Above is just some test code for me to learn how to program with backbone and jqm.

Initially, I think it's always better to start running my code when the document is ready, so I wrap backbone view creation logic in the document ready function: $(function(){ }). But the page is just not showing like a mobile app.

So I tried and tried, and I found when I remove the document ready function part, the page will be displayed correctly, exactly like a mobile app.

What's wrong with document ready function here? Please help.


Solution

  • I guess that you are applying some Backbone manipulation for elements like #homepage which is trying to manipulate by JQM too. That's why you don't have any problem if you remove the document ready function. You can do this Backbone code inside JQM page event functions. JQM page events. So the other code works after the pages are rendered by JQM.