5

I'm trynig to work on a phonegap applicaion but I don't know realy how to build the architecture.

I try a kind of MVC model with a big js for a controller, a js file with ajax request to get infos from the server (model) .

For the views I use a main layout with a header and a head.

I update my content using load in JQuery.

I have some problems using this system for exemple the previous button close the application because I always using the same page. When I rotate my screen I come back to the first screen because the page is refresh.

I'd like to know if you have some solutions or some code sample to begin with good bases

Thanks

Gajotres
  • 57,309
  • 16
  • 102
  • 130
Ajouve
  • 9,735
  • 26
  • 90
  • 137

1 Answers1

4

It depends how much do you want to change your current project.

In case you don't mind doing complete app revamp think about using Phonegap with jQuery Mobile + Backbone.js or Phonegap with Kendo UI. You already stated that jQuery is used for content loading so jump to jQuery Mobile is not going to be that problematic.

You can still use MVC doctrine with backbone.js and jQuery Mobile will handle page handling/transitions/UI. Only problem with this solution is possible performance issues in case you create too complex app. But this will happen to you no matter are you creating everything from the scratch or because you are using UI frameworks.

If you are willing to give it a try take a look at my other answers on related questions:

  1. Frameworks and little something about them: https://stackoverflow.com/a/14166593/1848600
  2. Phonegap + jQuery Mobile tutorials: https://stackoverflow.com/a/14375842/1848600

While Phonegap + jQuery Mobile is far from perfect combination it is still one of the best there is and it will save you a lot of time.

EDIT :

As you are using jQuery Mobile you can have a persistent header and footer if you use:

...data-position="fixed" data-id="footer"...

in both of them.

Here's my "how to" article on this question: https://stackoverflow.com/a/14417307/1848600

And here's a working example: http://jsfiddle.net/Gajotres/Beq4H/

Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • Thanks I am using Jquery mobile, but I don't realy understand how to change page keeping my layout, I don't want to rewrite my layout on each page. Thanks for your answer, I'll have a look to backbone.js – Ajouve Jan 21 '13 at 13:37
  • I dont understand you what do you meen by "how to change page keeping my layout"? If you can clarify it maybe I can help you further. – Gajotres Jan 21 '13 at 13:39
  • For exemple I want the same header in all my pages, if I have index.html, menu.html, actu.html. Is there a solution to generate the same head, and header in each pages ? – Ajouve Jan 21 '13 at 13:44
  • Yes there is, I will give you an answer in my main answer, give me a sec. – Gajotres Jan 21 '13 at 13:46
  • Take a look now. Feel free to contact me through my mail if you need more help. – Gajotres Jan 21 '13 at 13:50