Jump to content

Sortable Menu - Get only menu 1 items


jarvis

Recommended Posts

Hi All,

Am sure this is simple but can't work it out. I have the following which creates 3 menus:

<p>Drag items from one menu to another</p>
<table>
	<tr>
		<td valign="top">Menu 1</td>
		<td valign="top">Menu 2</td>
		<td valign="top">Menu 3</td>
	</tr>
	<tr>
		<td valign="top">
		<ul class="sortable" id="menu1">
			<li id="id_1">Item 1</li>
			<li id="id_2">Item 2</li>
		</ul>		
		</td>
		<td valign="top">
		<ul class="sortable" id="menu2">
			<li id="id_3">Item 3</li>
			<li id="id_4">Item 4</li>
		</ul>		
		</td>
		<td valign="top">
		<ul class="sortable" id="menu3">
			<li id="id_5">Item 5</li>
			<li id="id_6">Item 6</li>
		</ul>		
		</td>
	</tr>
</table>

This uses the following to show an array of each menu:

$(function() {
 $("ul.sortable").sortable({
    connectWith: '.sortable',
    update: function(event, ui) {
    $('#menu_choice').empty().html( $('.sortable').serial() );
    }
  });
});

(function($) {
$.fn.serial = function() {
 var array = [];
 var $elem = $(this); 
    $elem.each(function(i) {
      var menu = this.id;
        $('li', this).each(function(e) {
                array.push( menu + '['+e+']=' + this.id  );
        });
    });
    return array.join('&');      
    }
 
})(jQuery);

What I'd like is to simply grab the values of menu 1 only, as the array shows all menus. What am I doing wrong as can't seem to just return menu1.

Going forward, I then want to store the returned array into a PHP cookie if this is possible?

 

Many thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.