Closed Kikketer closed 11 years ago
Hi, sorry for the late answer, I was finalizing a couple of new features.
I've somehow fixed the examples but I've never used require before, so take it with a grain of salt (the requirejs example was kindly provided by another user).
Backbone is used very poorly in this example, I was in a rush when I first wrote this sh*t, I'm sorry, again.
Due to the asynchronous nature of require.js, there are a couple of steps (dependencies?) to be enforced:
1) the router must be loaded before jquery mobile 2) the router must be instantiated before jquery mobile initializes itself 3) the application won't be able to access the $.mobile namespace until jquery mobile is loaded
since rule 2 and 3 kind of contradict themselves, internal jquery mobile events must be used (mobileinit), so we have another rule
4) the router should bind to mobileinit before your application code
I'm sure there are better ways to do this, hopefully someone who has mastered requirejs will fix my patch.
Cheers, Andrea
Thank you for updating them, I actually took what you had to a different step but what you had really helped. Would you consider publishing your plugin on Bower? I would like to include it in a Backbone + RequireJS + jQuery Mobile template I'm making for my team.
Thanks!
So in the documentation you have "the router should be instantiated as soon as possible, possibly just after loading jquery mobile. This ensures that even the first pageinit event can be catched and handled by the router"
I've followed the exact method of initializing as you have in your backbone-requirejs-example. But it doesn't seem to catch early enough to render the first page.
I would like to, for example call a method on the controller for the very first page. Your example just has all the first page buttons written in the HTML. I would like to run a Backbone.View render to build that from a template. Any suggestions?