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
https://forums.phpfreaks.com/topic/289366-sortable-menu-get-only-menu-1-items/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.