Solved

jquery draggable

Posted on 2014-09-08
2
300 Views
Last Modified: 2014-09-08
Hi, I am very close to solving this just need a little push. I have a script that I am writting that allows you to drag an image. When you let go I want to send the position to data.php that will then record it. In firebug I used console.log and can see the x and y but when I pass the data I get object object.

Here is my jquery (it has php mixed in)
<script>

$(function() {
$( "#draggable<?=$x;?>" ).draggable({
        snap: true,

        drag:
                function(event,ui) {
                        theUserPos<?=$x;?> = ui.position;
                        console.log(theUserPos<?=$x;?>);
                },

        stop:
                function ( event, ui ) {
                        alert(theUserPos<?=$x;?>);
                        // parameters will be a string "id[]=1&id[]=3&id[]=10"...etc
                        //$("#info").load("update.php?"+theUserPos<?=$x;?>);





                        // send new sort data to process
                        $.ajax("data.php?"+theUserPos<?=$x;?>);
                }


        });

});
</script>

Open in new window


URL: http://rack.customphpdesign.com/index.php?action=new_rack&type=1/3
0
Comment
Question by:Robert Saylor
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
Comment Utility
Because ui.position is an array of the top and left values, to get either one use

ui.position.top
ui.position.left
0
 
LVL 6

Author Closing Comment

by:Robert Saylor
Comment Utility
Thanks Gary that worked! I tried to follow the docs :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now