Solved

jquery draggable

Posted on 2014-09-08
2
308 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 7

Author Closing Comment

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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

809 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