Solved

jquery draggable database update

Posted on 2013-02-04
11
273 Views
Last Modified: 2013-02-25
In my previous post http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28019313.html#a38852724

I show the code to what I am trying to do . now i need to be able to update the database when dropping the draggable into the small (area. The area when I just dropped the item basically overwrite the previously dragged item  )
0
Comment
Question by:erikTsomik
  • 6
  • 5
11 Comments
 
LVL 19

Author Comment

by:erikTsomik
ID: 38853147
any suggestions
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38853155
update the database using ajax, why not, but what is and where do you gett the data you want to send?

<li id="997" class="draggable ui-draggable" style="position: relative;">test1</li>

You want to send the id? For example you previously put li with id 998 in the droppable and now you put 997
So you send something like { id:997, previousid:998 }
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 38853667
yes that is exactly right. I will send 2 ids
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 82

Expert Comment

by:leakim971
ID: 38853682
 drop: function(e, ui) {

     var previousid = $(".previouslyDroppedClass").attr("id");
     var id =  ui.draggable.attr("id");
     $(".previouslyDroppedClass").removeClass("previouslyDroppedClass");
     ui.draggable.addClass("previouslyDroppedClass");
     // AJAX CALL USING POST METHOD
     $.post("yourURLhere", { "id":id, "previousid":previousid }, function(messageFromCF) {});

// your previous code here

}

Open in new window

0
 
LVL 19

Author Comment

by:erikTsomik
ID: 38860941
it is always update the last dropped element what if i need to update the one that was dropped before
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38860955
in your coldfusion code get previousid parameter value not id
of perhaps you don't need the new one so just pass previousid
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 38860983
I may not have a coldfsuion code for that page. The new post is here

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28022506.html.


Really having a hard time figuring out this issue
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38861019
I may not have a coldfsuion code for that page. The new post is here

I dunno but if you're using ajax you have server side process, no?

so it's the same logic for any language, just send the right id to the right server side page/functio to remove the right data/row from your database.
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 38861036
right . Like I said I made some changes to the code which I shown here
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28022506.html.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 38861070
So you as for a solution, I give you a code, you don't use it or give any feedback
what can I do?
 drop: function(e, ui) {

     var previousid = $(".previouslyDroppedClass").attr("id");
     var id =  ui.draggable.attr("id");
     $(".previouslyDroppedClass").removeClass("previouslyDroppedClass");
     ui.draggable.addClass("previouslyDroppedClass");
     // AJAX CALL USING POST METHOD
     $.post("yourURLhere", { "id":id, "previousid":previousid }, function(messageFromCF) {});

// your previous code here

}
0
 
LVL 19

Author Comment

by:erikTsomik
ID: 38861120
NO  I do not use that piece because I reconstruct the code a little. Please take a look at this post
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28022506.html.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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…

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