开发者

Jquery draggable persistence either through mysql or saving cookie in the database?

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',
                                                            });
                                                    }
                                                });
                             开发者_如何学C                   $(".draggable").draggable({
                                                    helper: 'clone',
                                                    tolerance: 'touch',
                                                    cursor:'move'
                                                });

});



  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.


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

jQuery UI sortable: determining in what order the items are

and this:

Getting the position of the element in a list when it's drag/dropped (ui.sortable)

hope this help


There's a nice tutorial and demo of how to drag-and-drop with PHP,jQuery-UI and MySQL here: PaperMashup

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜