Jump to content



Photo

Bootstrap - Jquery sortable


  • Please log in to reply
1 reply to this topic

#1 Craig Hopson

Craig Hopson

    Neowinian

  • Joined: 17-November 12
  • Location: London
  • OS: Windows 8 :-(

Posted 17 June 2013 - 19:01

Hi guys i have a question i have this Jquery function which works fine

$(function () {
    $(".Movable").sortable({
            tolerance: 'pointer',
            revert: 'invalid',
              placeholder: 'span2 well placeholder tile',
            forceHelperSize: true,
            update: function(event, ui) {
                order = $('.Movable').sortable("toArray");
                $.ajax({
                        type: 'GET',
                        url: My_Site+'/themes/mytheme-2/ajax.php?task=Order&user_id='+User_ID+'&orderby='+order,
                        timeout: 2000
                });
            }
        });
});

It saves it into a mysql database under the users_id

 

SO my question is how do i reverse the function to get the order via AJAX and sort the .Movable class

 

Thanks




#2 OP Craig Hopson

Craig Hopson

    Neowinian

  • Joined: 17-November 12
  • Location: London
  • OS: Windows 8 :-(

Posted 17 June 2013 - 19:12

ok i've updated the function to this

$(function () {
	$(".Movable").sortable({
        	tolerance: 'pointer',
        	revert: 'invalid',
      		placeholder: 'span2 well placeholder tile',
        	forceHelperSize: true,
        	update: function(event, ui) {
        		order = $('.Movable').sortable("toArray");
        		$.ajax({
            			type: 'POST',
            			dataType: 'json',
            			url: My_Site+'/themes/mytheme-2/ajax.php?task=Order&user_id='+User_ID,
            			timeout: 2000,
            			data: {orderby:order}
        		});
    		}
    	});
});


and this is the value that is saved

["friends","notifications","messages","search","member_online","new_member"]

SO how do sort the div's by "id" as saved