I'm developing a social network website and I'm working with php/mysql/jquery and I want users to have the most user-friendly website experience. That's why I try to avoid a save (submit) button at all. So, when they're on their own profile and enter information like what languages they speak or where do they live, I want to auto-create a page entry, if it doesn't exist already.
For example if somebody speaks german and that entry isn't available in the database yet (it's called pages
with rows title
, text
, date_added
). This is most likely comparable with a Facebook page you can create on Facebook, but this should be about everything (languages, companies, locations, activities).
So my specific problem now is, how to implement this feature the most smartest way. I mean on what event should this save be triggered, because I obviously can't save a new entry on every letter that has been typed. I've already implemented an autocomplete function, so they can choose from entries that already exist, but as mentioned I want them to create new entries (pages), too. Most preferably without "flooding" the database with new entries.
The things I thought of:
When a user switches from one input to another and input has been made. Can this even be registered by JQuery? But here's the question, what if he leaves the page without switching to another input.
Save all data only then if he leaves the current page. I think there is this
onunload
function in JQuery.Get confirmation from the user: "This entry hasn't been made yet. Do you want to save this entry?". But when should I ask this? I can't predict when the user is finished with typing.