I have a relatively simple web application that functions like a kiosk, which I am currently revising. My initial goal was to make it work, but now I'm trying to implement a more elegant approach.
Basic background information:
- Content - all content comes from the database through php - either answers ajax calls, or directly reflects on content with php (most of the content). This part, which I have already reviewed and is not yet perfect, is quite effective / flexible.
- What the kiosk does - our customers take one or more polls using the kiosk. Data is transmitted after the form is confirmed. If this is the last poll, the session ends. If there are more polls, they continue to conduct polls.
Problem: I have a mess of jQuery event handlers that control kiosk behavior. Basically, the behavior is to show / hide elements that are already in the DOM, depending on the state of the kiosk.
- command switching
- switching the exit screen (completion of the survey)
- go to next / previous survey question
- an idle timer that displays warnings for automatic logout (again, just show / hide no warning)
- Show skipped questions if there arenβt enough answers.
- submitting the form if it passes a simple check
The more surveys I add, the more frequent cases I encounter and the mess that jQuery seems to get. Surveys that consist of only radio buttons are easy (although the code is still not neat), but I seem to consider those who have questions and answers (questions that depend on other questions) and text answers as special cases when I would like to use a more modular / OOP approach to jQuery.
I reviewed ...
- Prototype
- jQuery UI Widget Factory
- Writing your own jQuery module
- Writing your own javascript class
- Knockout.js
- Continuing the current jQuery approach, just clear it.
Thank you in advance for suggesting your experience and pointing me in the right direction, depending on the context of my project.
source share