Solved

jquery draggable database update

Posted on 2013-02-04
11
270 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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 …
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 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…

707 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

13 Experts available now in Live!

Get 1:1 Help Now