What is the best way to work with jQuery Mobile for dynamic pages?

This is really frustrating ..!

When working with jQuery Mobile with predefined pages, everything goes smoothly and easily, but what about more complex projects?

I am working on a survey system that displays the next page based on a previous answer. Therefore, each page should pass the current question to the external API and get the next question.

My first choice was to progress through JS, but the main problem was that the data had to be sent through AJAX, and then the input of the new structured HTML had to be “updated” before doing well. In addition to this, all AJAX requests must have their callbacks that create messy code. So, in my case, a survey containing 20-30 questions, consisting of 15 different types of forms, has a lot of use for callbacks and nested callbacks.

Then I rewrote the project using PHP as a base. forms (containing survey questions) that are sent to the same page with one instance of "data-role = page". With the CURL request, I send the answer and get the next question, generated the HTML structure and voila - it all does great, without having to start the update.

But using this method has its problems:

  • sending to the same page deprives you of transitions to the page and you will have a default transition.
  • jQuery mobile has this weird caching (even after I used each method to disable it)
  • data transfer from page to page is complicated - GET - length
    limited and POST does not meet my needs, because the actual CURL request had to be sent "param1 = val1 & ..")

So, what is the best way to work with jQuery Mobile when working on a complex and dynamic project?

Thanks,

+4
source share
1 answer

Good IMHO (Based on PHP and jQM). I used the JSON approach served by PHP and then figured out jQM.

My approach is to create a landing page (a page with dynamic content) to store the required functions, such as Navigation, Logo, Header, Footer, etc ... and jQM updates the contents of the page using the sent JSON from the PHP response.

You can also associate this with localstorage using storage.js

Now I will also show (but not yet used) some information on using the template engine, for example Handlebars, here are some links that I found that might be interesting to read:

0
source

All Articles