How can I implement MVC architecture using jQuery mobile

I am developing a jquery mobile app with php serverside. I want to know if there is a way to separate views, controllers and models on jQuery mobile.
Beacause of writing views and controllers in a single file will mess with the files.
How to implement MVC architecture in jquery mobile .

+4
source share
5 answers

After all my searches I have found, the js spine will solve my problem, I think. backbone.js 2

backbone javascript provides views, models, and collections to achieve MVC architecture with jquery mobile. But still, search is how compatible it is with Google maps, such as driving patterns and map directions.

Please discuss your thoughts.

0
source

You should not have any jQuery mobile code in your controllers or models.

I'm not sure what exactly you mean by "I want to know if there is a way to separate view controllers and models in jQuery mobile" - this is all PHP, jQuery mobile should exist only in your views.

Just create a normal MV MVC setup and use jQuery for mobile in views.

I used jQuery mobile on rails site and just created .mobile and .tablet view for each page. jQuery mobile only affects the appearance, its pure look.

edit: There were a few more rails that ran "mobile or not", but since you are in php, which is not worth delving into.

+2
source

Take a look at Knockout . This is not MVC, but the MVVC framework, however it will provide you with a separation of the view from the logic you are looking for. Here is an example and jsFiddle prototype using it with JQM.

+1
source

It is fairly easy to integrate it with CakePHP . I used it a bit and it is simple and intuitive.

0
source

You should not combine models, views, and controllers with you in the javascript layer (unless you use something like Knockout.js, in which case you don't even need PHP)

If you use server-side programming, then Javascript is just an enhancer for your views.

Just use any PHP MVC framework and display different views depending on the browser (mobile or work). Then use jquery mobile to render the mobile version.

0
source

Source: https://habr.com/ru/post/1435203/


All Articles