views:

182

answers:

2

I want to know that how can I persist the divs dropped on a draggable. I have been trying since long but stuck at this point. Actually you can see the demo here. I have to save the user designed wedding floor. So whenever user logins next time he/ she is able to see the last design saved. The code is shown below:


                                             $(document).ready(function() {
                                                $("#droppable").droppable({
                                                    accept: '.draggable',
                                                    drop: function(event, ui) {
                                                            $(this).append($(ui.draggable).clone());
                                                            $("#droppable .draggable").addClass("objects");
                                                            $(".objects").removeClass("ui-draggable draggable");
                                                            $(".objects").draggable({
                                                                    containment: 'parent',
                                                            });
                                                    }
                                                });
                                                $(".draggable").draggable({
                                                    helper: 'clone',
                                                    tolerance: 'touch',
                                                    cursor:'move'
                                                });

});


A: 
  1. Get Position of each Object (easy to do with JQuery)
  2. Serialize to JSON and save to a database of your choice. Don't use cookies for this.
Dänu
A tutorial or sample code would be good.
Muhammad Jehanzaib
do you use mysql as a database? on what do you need an example, the database connection part? the serialization?
Dänu
Yes i use mysql as the db. I want to know the actual code to pass the data from jquery to php using json. Furthermore what I have to do after passing those values in php code to save those values in mysql.
Muhammad Jehanzaib
A: 

I have already asked to this kind of question read this:

http://stackoverflow.com/questions/2669130/jquery-ui-sortable-determining-in-what-order-the-items-are/2669215#2669215

and this:

http://stackoverflow.com/questions/2442232/getting-the-position-of-the-element-in-a-list-when-its-drag-dropped-ui-sortable/2443081#2443081

hope this help

aSeptik
I want to know the actual code to pass the data from jquery to php using json. Furthermore what I have to do after passing those values in php code to save those values in mysql.
Muhammad Jehanzaib