Building an Organized jQuery Mobile App with PhoneGap

Currently, I'm developing a game in phonegap using the jQuery Mobile framework. As my project has progressed, I've noticed that my code has turned into a tangled mess of spaghetti with one HTML file and several JavaScript classes.

I'm curious if there are any resources available for creating a well-structured jQuery Mobile Application following the MVC pattern.

I stumbled upon a helpful guide for building an MVC App with Sencha Touch. I'd like to find something similar tailored to jQuery Mobile.

Answer №1

In organizing my rather large application, I have structured it as follows:

css
    -- contains all css files
images
    -- contains all image files
js
    controller.js -- handles page events and element actions, also includes PhoneGap specific methods
    core
        forms.js -- manages form functionality and info saving
        mobile.js -- defines basic elements, handles AJAX communications
        encrypt.js -- deals with encryption
        global.js   -- provides helper functions
        storage.js  -- acts as a database storage wrapper
    cw
        client.js -- a complex client object with over 400 lines of JavaScript code
        Objects.js -- includes other necessary objects with less than 50 lines of code each
        question.js  -- a detailed question object with over 500 lines of code
        service.js    -- a comprehensive service object with over 700 lines of code
    jq
        jquery-ui.min.js
        jquery.min.js
        jquery.mobile.min.js
        phonegap-1.1.0.js

add_client.html
clients.html
client_list.html
index.html            -- the only complete HTML file
manager.html
schedule.html
service.html

Except for index.html, all other .html files serve as placeholders. They include

<div data-role='page'></div>
and essential html elements defining the page's intended functionality.

I develop the app using VS2010 and debug on Chrome. Once satisfied with progress, I transfer everything to a folder in an Eclipse project on my Mac (for Android devices), which is linked to my xCode project (for iOS devices).

After 3-4 months of work and overcoming learning curves with jQM and PhoneGap, I have found great success with this structured approach.

Answer №2

Did you check out the information on the wiki?

If you want to see some code, take a look at this:

Sample Application using jQuery Mobile and PhoneGap

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

There appears to be a syntax error in the Values section of the .env file when using nodejs

I have been working on implementing nodemailer for a contact form. After researching several resources, I came across the following code snippet in server.js: // require('dotenv').config(); require('dotenv').config({ path: require(&apos ...

Using Regular expressions in JavaScript to eliminate content between two HTML comment tags

I am currently dealing with two HTML comments in this format: <!--Delete--> Blah blah blah blah <!--Delete--> I need to remove these comments, along with any characters and newlines. I am utilizing JavaScript and Grunt for this replacement ta ...

Resolving cached CSS and JS files through the use of local storage

My customers frequently express frustration over not seeing the improvements I've made to my CSS or JS effects. The issue seems to be related to cached files. Perhaps this code snippet could provide a solution: $(document).ready(function(){ va ...

Is there a method to display the Freshservice app on portal pages specifically for Requesters' view?

Here is what I need: 1. The user will input a subject. 2. Based on the subject, I need to make a call to a third-party REST API (Unfortunately, it is currently blocked by CORS and even JSONP requests are not working). 3. After receiving the response, I w ...

Is it possible to trigger a script tag based on certain conditions using a JavaScript function?

I'm currently working with Angular and have a requirement to trigger a third party script from a function located within another script tag. Here's an example scenario: Within the index.html file let displayOnHomepage = () => { if (win ...

Getting rid of the final ng-form from validation within angularjs

Within my AngularJS application, I have implemented a master detail form for handling transactions. The form consists of standard master data fields such as Name and Type, along with a detailed section that allows users to add and delete multiple lines. Ea ...

React Full Calendar Error: Unable to access property 'calendar' from undefined

I'm encountering an issue while attempting to save selected time information in state. Any assistance would be greatly appreciated, thank you for your help! Please feel free to ask if more specific details are required. Below is a snippet of code fro ...

Bootstrap UI Tab presents an obstacle for Google Map functionality

When utilizing the Bootstrap Tabset to include a Bootstrap slider, Google Map, and other pages, I encountered an issue where the slider functions perfectly but the Google Map does not work as expected. Interestingly, the map works perfectly in street view ...

What is the best way to utilize both doPost() and doGet() requests in a single servlet while incorporating ajax technology?

Currently working on a small project involving JSP servlets. I need a practical example demonstrating the implementation of both the doGet() and doPost() methods within the same servlet, while handling AJAX calls within a JSP form. Additionally, could you ...

Navigating the waters of managing setInterval within a Nuxt environment

Within my component, I have a timer that is initiated using setInterval in the mounted() hook. Let's say this component is located at http://localhost:3000/some-route. What is the best approach to call clearInterval() when navigating to another rou ...

Installing external Javascript libraries on Parse cloud code can be done by following these steps

Currently, I have integrated these JavaScript libraries into my Parse cloud code. var request = require('request'); var fs = require('fs'); var Twit = require('twit'); However, the code refuses to compile if these libraries ...

Making an Ajax Request to Retrieve Data from Multiple URLs

Currently, I am attempting to perform an ajax call using the following URL: . The page number in the URL needs to be dynamic based on the response received from this ajax call. Here is my current code snippet: $.when( $.get("http://exampleurl ...

Is there a way to specifically target CSS media queries if the device resolution is similar, but the device screen size (measured in inches) varies

I possess two distinct gadgets. 1. T2 light - LCD : 15,6“ Resolution : 1920 × 1080 Device pixel ratio : 1.4375 CSS media query target : width = 1336px 2. T2 mini - LCD : 11,6“ Resolution : 1920 × 1080 Device pixel ratio : 1.4375 CSS media query t ...

What is the proper way to refer to an array or object within a function in JavaScript

Greetings! I am facing an issue with a JavaScript array declared outside of a function as shown below: var daily = []; daily["data"]=[]; daily["data"].push('hello'); function demo() { console.log(daily); // not working here } Can anyone advise ...

The mark-compacts were not efficient enough, they approached the heap limit and as a result, the allocation failed. The JavaScript

Currently working with Angular version 7.2 and encountering an issue when running ng serve: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory What does this error mean? How can it be resolved? The ...

What is the best way to extract all of the JSON data from Firebase using a web platform?

As a newcomer to Firebase and noSQL databases, I'm encountering difficulties in extracting all the JSON data from the database. Although I've gone through the firecast tutorials and understand how to retrieve specific values by referencing the da ...

Troubles encountered with the onclick event handling

Hey there, I've created a GSP and JavaScript code for implementing a functionality that removes files on click. JavaScript snippet function remove(attachmentId) { $(document).ready(function(){ $('.glyphicon-remove').click ( ...

The problem with React useState not updating could be due to useRef interference

I'm facing a strange issue with my React code: the useState function is not updating the view, despite trying everything to fix it. To illustrate the problem, I have created a simple example: function(){ const [enterJob, setEnterJob] = useSt ...

Exceeded Limit: Google Maps API cannot process more than 10 destinations at this time

After spending the entire day researching, I am still unable to find a solution that solves my issue. I am utilizing the Google Maps Distance Matrix Service with 1 origin and 14 destinations. While testing the modified sample code from Google (https://deve ...

Password Field Validation in React

<TextField id="outlined-basic" label="Password" variant="outlined" /> Can anyone assist me in implementing password validation using an onchange function? I am seeking help with the ...