Solved

jquery draggable

Posted on 2014-09-08
2
311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery not working after div reload 4 35
Google Tag Manager - Add Trigger Using Div class 22 58
Html using "Or" in condition 3 27
GitHub 1 9
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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)
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…

749 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