SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    adding ajax to jquery ui accordion

    Hello all... PHP guy here just getting into javascript/jQuery...

    I'm using jQuery's sortable accordion (http://jqueryui.com/accordion/#sortable) in an application to display elements that are in a set order. I was wondering if anyone could point me in the right direction on how to add ajax functionality to this so that when a user reorders the accordion list the order is updated on the server side.

    I'm sure this is pretty basic ajax stuff but i'm a complete noob with client side scripting

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,859
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    I'm guessing that the accordion uses jQuery UI's draggable functionality.
    If that is the case, then you probably want to listen for the "stop" event, which fires when a drag operation has finished.
    See also: http://jqueryui.com/draggable/#events

    Then you can hopefully do something like this:

    Code JavaScript:
    $( ".selector" ).on( "dragstop", function( event, ui ) {
      $.ajax({
        type : "POST",
        url : "myScript.php",
        data  : 'var=' + myVar,
        success : function(data) {
          //do something
        }
      });
    });

    You might want to check out: http://api.jquery.com/jQuery.ajax/

    Hope that helps.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •