Sign in to follow this  
Followers 0

Bootstrap - Jquery sortable

2 posts in this topic

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.