Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2010
    Location
    In a dump
    Posts
    64
    Thanks
    9
    Thanked 2 Times in 2 Posts

    Jquery Move Tracking

    I have made a page with 3 columns with sortable divs. I need to be able to track the divs when they are moved so that when the user closes the page the divs will be in the same locations they were moved to. I got the following code from the BBC website yet I cannot get it to work. Anyone know what is wrong with it?

    Code:
    Code:
    function update_positions(e, ui){
    	var widget_cookie_positions = loadCookie('iARC_widget_positions');
    	var moved_widget_id = $(ui.item).attr('id');
    	var moved_to_column_id = $(ui.item).parents('.column').attr('id');
    	var column_order = "0";
    	
    	$('#' + moved_to_column_id + '> .widget').each(function(){
    		
    		var widget_id = $(this).attr('id');
    		
    		panel_positions[panel_id] = moved_to_column_id + ':' + column_order;
    				
    	column_order++;	
    		
    	});
    };

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    It's not saving the new positions?

  • #3
    New Coder
    Join Date
    Jan 2010
    Location
    In a dump
    Posts
    64
    Thanks
    9
    Thanked 2 Times in 2 Posts
    Sorry, I should of said. All it does is crash the sortable when you move the divs more than once. I tried writing to a cookie but this does not work either.

  • #4
    New Coder
    Join Date
    Jan 2010
    Location
    In a dump
    Posts
    64
    Thanks
    9
    Thanked 2 Times in 2 Posts
    If anyone is interested in this post, I have managed to work out that the reason the sortable is crashing, the console that I have is showing that the this.helper is null and therefore stuck in a ever running loop. I am trying to sort out this issue and I will post the working code once it has been rectified.

  • #5
    New Coder
    Join Date
    Jan 2010
    Location
    In a dump
    Posts
    64
    Thanks
    9
    Thanked 2 Times in 2 Posts
    Code:
    function update_positions(e, ui){
    	var widget_cookie_positions = loadCookie('iARC_widget_positions');
    	var moved_widget_id = $(ui.item).attr('id');
    	var moved_to_column_id = $(ui.item).parents('.column').attr('id');
    	var column_order = "0";
    	
    	$('#' + moved_to_column_id + '> .widget:not(this.helper)').each(function(){
    		
    		var widget_id = $(this).attr('id');
    		
    		panel_positions[panel_id] = moved_to_column_id + ':' + column_order;
    				
    	column_order++;	
    		
    	});
    };
    Works Like a charm now. If you cannot see I have changed the code to exclude the helper which has stopped the loop.


  •  

    Posting Permissions

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