Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-30-2008, 12:59 AM   PM User | #1
Aitchy13
New Coder

 
Join Date: Dec 2007
Location: Jersey, UK
Posts: 17
Thanks: 0
Thanked 2 Times in 2 Posts
Aitchy13 is an unknown quantity at this point
jQuery UI Cookie

Hello there.

Whilst working on a web application I have come to a point where I am finding it difficult to progress, so I am posting here today in hope that someone will be able to answer my question, or give me some pointers as to how I should tackle this problem.

I'll start off by giving some background information as to how this application functions, and will talk about the technical side of it later on. Effectively what I am creating is a virtual noticeboard for staff members to login to where they can view a noticeboard that displays multiple notes. The standard user cannot make notes, but can hide notes that they have read. When doing this, only the notes hidden will affect that particular user. Each user can also move each note around to whatever position they want, however, I am having issues saving the position they move this note to.

I am using jQuery UI to make each note movable. Each note is contained by a parent <div> (the noticeboard) and is restricted to move only within the parent <div>. Each note is created dynamically using PHP (created by an admin). As I mentioned before, I am having issues with storing the position of each note that is moved by each user, so that when they login again, the note is still in the same spot they last dragged it to.

From what I can understand I need to create a cookie that will store the 'top' and 'left' values of each note, and then re-position each note when the page is loaded based on those values. This is where I come to a halt. Having relatively little experience in Javascript, I am really stuck when it comes to putting this idea into actual code.

So, my question. How would I write this cookie to store and read the position of every note that is created? Secondly, could this cookie be written so that it would work across all users, or would I need to approach this differently?

Thank you very much for giving the time to read over my problem, and any feedback will be greatly appreciated.

James
Aitchy13 is offline   Reply With Quote
Old 07-31-2008, 01:54 PM   PM User | #2
M@rco
Regular Coder

 
Join Date: Oct 2003
Location: London, UK
Posts: 411
Thanks: 0
Thanked 1 Time in 1 Post
M@rco is an unknown quantity at this point
The problem with cookies is that they would only store the note position/visibility data on that particular user's local profile on his PC (unless you have profile roaming, and I'm assuming a Windows environment here of course). Surely what you want is for any user to log on from any PC anywhere and find the notes exactly as he left them?

Well, presumably you're authenticating the users anyway and are therefore storing their account details in a database, along with the notes created, etc. So I suggest that you store the *state* of each note for each user in the database too, recording the state every time the note is moved/hidden/shown via an AJAX call to the PHP backend (to update the database). To reduce the number of records being stored/manipulated you should only create a user's note record where the data differs from the base values for the note (i.e. when created by the admin, as stored in the note record).

Then, when a user logs in, use AJAX to retrieve and draw all the notes he has access to with any overridden or visibility settings for the user, driven by a suitable SQL query which joins the data tables together and overrides the base values where the user has made a change.
__________________
Marcus Tucker / www / blog
Web Analyst Programmer / Voted SPF "ASP Guru"
M@rco is offline   Reply With Quote
Old 07-31-2008, 03:36 PM   PM User | #3
Aitchy13
New Coder

 
Join Date: Dec 2007
Location: Jersey, UK
Posts: 17
Thanks: 0
Thanked 2 Times in 2 Posts
Aitchy13 is an unknown quantity at this point
Hi M@rco

I appreciate the detailed response, however, I am dealing with the design and presentation side of the project and have been advised that cookies will be suitable as the users will be using the same computer every time anyway.

With that in mind, how would you recommend I pursue with this issue?

Thanks,

Aitchy13
Aitchy13 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:06 AM.


Advertisement
Log in to turn off these ads.