This next user customization is for more modern applications that apply Web 2.0 functionality in them. Some of this functionality is in moving objects around on a page. When the application in question truly is living up to its name as an application, any changes the user makes should be saved for the next time that same user uses the application. One of these user-customizable options is the position of objects on a page.
For now, let's assume the user can move objects on the screen without going into detail regarding how this is accomplished. We need to keep track of the final x and y coordinates of the object once it has moved, as well as what object was moved. The easiest way to store this information is in a simple multidimensional array, where the first index stores the object being moved and the second index stores an array containing the object's x and y coordinates. When the page initially loads, there should be a call to the database to move any objects that were moved from their original position when the user last used the application. It is that simple to save position!
OK, seriously, first we need to allow the object to be moved
or dragged around in the application. In Chapter 10, I introduced you to the
Draggable script.aculo.us object.
Using this object is the easiest way to move an object to a new
position, and by using the
snap object, you can exert the tiniest bit of control over where the ...