-
pinakdas163 Newbie

-
Posts: 2
Threads: 1
Joined: Jan 2017
Reputation:
0
(01-25-2017, 04:49 PM)PaulD Wrote: Hi,
Not sure if this will help but you could rewrite it to work in this way.
The form is loaded in the pop up in the normal way inside a view, not via ajax, but as part of the main page view, except in your case it is in a non-displayed pop up window but still originally written in normal HTML view formats.
Instead of submitting the data via a normal post button, the button is not enabled via js but instead runs your script.
Your script collects all the relavant post fields and submits via ajax to a controller, that process the data and returns either 'ok' if succesful or if not the validation errors. Your script either displays the error messages (html injection to a relevant named div) or it closes the popup and does whatever you need it to do next. (redirect, refresh a user list, whatever...)
Having said all that, are you sure you are disabling the default post event on your form, sounds like it is being submitted from your description.
IMHO, forms inside popups is not a great user experience. Also it gets very complicated very quickly if you have to deal with errors like 'user already exists' or 'your login has expired', or any error that requires further input from the user. However that is just my opinion, but I find that ajax is at its most powerful when used where it is truly relevant, and truly most convenient for a user. A form like 'add user' is a typical example where there not only might be many return messages requiring further clarification, but also a serious enough action that a new page load should not be a problem. Also maintaining this code in the future will be a lot easier than what you are currently doing if the 'add user' functionality was seperated from your other page logic. For instance, later you might want to add a user that does not have certain privileges, or is not yet active waiting for some clearance or payment, or you might want to send an invite to them, or a custom message. Or have them added to a queue for moderation. All this might require further steps to the form, and a multi step ajax loaded and updated form can become a maintenance nightmare, with very little, if any, user benefit. Why not seperate it out to seperate pages and/or libraries or models so that if you need to add a user from elsewhere in your system, you can do so easily and quickly.
Ajax is great, but from experience, ajax heavy pages for little user benefit becomes a nightmare very quickly.
Anyway, hope that helps in some way,
Paul.
Thank you so much for your nice explanation. I started this project midway taking responsibility from another developer. I am definitely considering now to create separate pages for adding/editing user instead of popup window.
Pinak
|