Solved

jquery draggable

Posted on 2014-09-08
2
304 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
ID: 40311120
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
ID: 40311129
Thanks Gary that worked! I tried to follow the docs :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
alert before form submission 6 31
jQuery AJAX Redirects Without Response/Error 10 46
Replace &lt; with < 14 56
Angular - break the dataset in chunks? 7 39
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 …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…

920 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

17 Experts available now in Live!

Get 1:1 Help Now