Solved

jquery draggable database update

Posted on 2013-02-04
11
277 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
alert on input text 2 25
window close link 7 35
make control visible based off other control value 7 22
Glitching Slide Show 19 28
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 …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

726 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