Link to home
Start Free TrialLog in
Avatar of Colin Brazier
Colin BrazierFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Want to sort within multiple groups

I have a working jQuery sort where there is one parent div and one child level of divs.

#tnewsList > .admin_block

I have added an additional layer of divs called .item_group so now I have

#tnewsList >  .item_group > .admin_block

I want to be able to move admin_blocks within their existing item_group but not into another item_group, and record the new order, when saved, into my database.  The item_groups themselves should not be able to be sorted within the parent #tnewsList.

I attach a piece of my html, and the working jQuery for the two-level html.

Thanks for reading, any help appreciated.
Capture2.JPG
drag_sort_151118_orig.js
Avatar of sajayj2009
sajayj2009

where are you passing 'thisis' variable?
Avatar of Colin Brazier

ASKER

Sorry I should have hardcoded that bit.

It comes from the html page here:

<!-- Used in drag n drop -->
<script type="text/javascript">
	var thisis;
	thisis = "letters"  // changes for each category.
</script>

Open in new window


and the controller checks $_GET to pass the control on to the correct page.
@sajayj2009

did that help you?
Avatar of Rainer Jeschor
Hi,
are you using the jQuery UI sortable widget? Or any other plugin?
I will have to provide a demo/sample on jsFiddle ...

Thanks
Rainer
Yes,  jQuery UI sortable widget

Here's what I have been playing about with:

$('.item_group .admin_block').each(function() {
            		/*myOrder.push($(this).attr("id"));*/
            		myOrder.push($(this).sortable('serialize'));
					/*serial = $(this).sortable('serialize');*/
					serial = $(this).sortable('serialize');
        			console.log(serial);  
        	});
        	console.log(myOrder.toString());  
        	console.log(myOrder); 
			tos_serial = myOrder.toString().serialize;
			myo_serial = myOrder.serialize;
        	console.log(tos_serial); 
        	console.log(myo_serial); 

Open in new window

jsfiddle would be fine thanks.
ASKER CERTIFIED SOLUTION
Avatar of Colin Brazier
Colin Brazier
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I apologise to Rainer.  

I am more upset with Sajayj because in my experience the first comment on a question puts a lot of people off as they think it's already being dealt with, and his comment had little to do with what I was asking about. Yes, I should have taken that variable "thisis" out of the code, but I did also pointedly ask him whether my answer to his question had helped, and I never heard back.

Cheers,

  Col
I figured it out myself.

If you cannot or do not intend to assist in a question further please let the asker know.