I'm working on a Javascript-heavy piece (using jQuery) for a website (at the moment, I'm working on getting a prototype going).
To summarize what I'm doing, I have a series of 'icons'. Each icon, at the moment, is an image. I also have a series of 'buckets'. The icons all start in a single bucket. The user is able to create new buckets and drag the icons around from bucket to bucket. The icons can also be turned on and off by clicking on them (although they still remain in their bucket).
I have it all working fine at the moment, however at the moment it's basically a bunch of img elements getting moved around from div to div. When I'm ready to start implementing the server-side logic, I'm going to need a way to communicate what's going on to the server.
What I need is a 'model' object reflecting what's going on with the view. It'd be good if when the user is ready to send the data back to the server, I'd have an object I could serialize representing what I need. For example, if the user has dragged the email.png icon into bucket the Options bucket, I would like for this to be reflected in a model object (i.e. { 'options': ['email'] }).
The issue is, all my logic is occurring based on events. When the user drags the icon to a div, an event is fired on the img DOM element, from which I'm not sure how to access it's model to update it. The only thing I can think of is parsing the img src and use that to find out the name of the model option but that's a very hackish and inelegant solution.
Any ideas?