Ik probeer de nestedSortable jQuery plugin te integreren om een boomstructuur te kunnen sorteren. De plugin heb ik alvast ingepast en het verplaatsen van de nodes en de node trees lukt aardig. Ik krijg echter geen data output wanneer ik net een verplaatsing heb gedaan. Hier is m'n script:

[code lang=js]<script>
$(function() {
$('.sortable').nestedSortable({
'listType': 'ul',
'handle': 'div',
'items': 'li',
'toleranceElement': '> div',
'isTree': true,
'opacity': 0.5,
'cursor': 'move',
'revert': 100,
'stop': function (event, ui) {
var data = $(this).nestedSortable('serialize');
console.log(data);
console.log('test');
// POST naar server ($.post of $.ajax)
$.ajax({
data: data,
type: 'POST',
url: '<?php echo $this->here; ?>'
});
}
});
});
</script>[/code]

De "test" print hij succestvol naar de console, maar de data toont hij helemaal niet. Ik probeerde ook al iets in de aard van:

[code lang=js]var data = $('.sortable').nestedSortable('serialize');[/code]

Hier is, voor de duidelijkheid, m'n HTML tree:

<ul class="tree sortable level-1">
	<li>
		<div class="wrapper">
			<div class="random"><span class="glyphicon glyphicon-random"></span></div>
			<div class="name">Pagina's</div>
		</div>
		<ul class="level-2">
			<li>
				<div class="wrapper">
					<div class="random"><span class="glyphicon glyphicon-random"></span></div>
					<div class="name">Toevoegen</div>
				</div>
				<ul class="level-3">
					<li>
						<div class="wrapper">
							<div class="random"><span class="glyphicon glyphicon-random"></span></div>
							<div class="name">Tweede niveau</div>
						</div>
						<ul class="level-4">
							<li>
								<div class="wrapper">
									<div class="random"><span class="glyphicon glyphicon-random"></span></div>
									<div class="name">Derde niveau</div>
								</div>
							</li>
							<li>
								<div class="wrapper">
									<div class="random"><span class="glyphicon glyphicon-random"></span></div>
									<div class="name">Derde niveau (2)</div>
								</div>
							</li>
						</ul>
					</li>
				</ul>
			</li>
		</ul>
	</li>
	<li>
		<div class="wrapper">
			<div class="random"><span class="glyphicon glyphicon-random"></span></div>
			<div class="name">Attracties</div>
		</div>
		<ul class="level-2">
			<li>
				<div class="wrapper">
					<div class="random"><span class="glyphicon glyphicon-random"></span></div>
					<div class="name">Toevoegen</div>
				</div>
			</li>
			<li>
				<div class="wrapper">
					<div class="random"><span class="glyphicon glyphicon-random"></span></div>
					<div class="name">Sorteren</div>
				</div>
			</li>
			<li>
				<div class="wrapper">
					<div class="random"><span class="glyphicon glyphicon-random"></span></div>
					<div class="name">Types</div>
				</div>
			</li>
			<li>
				<div class="wrapper">
					<div class="random"><span class="glyphicon glyphicon-random"></span></div>
					<div class="name">Eigenschappen</div>
				</div>
			</li>
			<li>
				<div class="wrapper">
					<div class="random"><span class="glyphicon glyphicon-random"></span></div>
					<div class="name">Constructeurs</div>
				</div>
			</li>
		</ul>
	</li>
	<li>
		<div class="wrapper">
			<div class="random"><span class="glyphicon glyphicon-random"></span></div>
			<div class="name">Nieuws</div>
		</div>
		<ul class="level-2">
			<li>
				<div class="wrapper">
					<div class="random"><span class="glyphicon glyphicon-random"></span></div>
                    <div class="name">Toevoegen</div>
                </div>
            </li>
        </ul>
    </li>
    <li>
        <div class="wrapper">
            <div class="random"><span class="glyphicon glyphicon-random"></span></div>
            <div class="name">Dieren</div>
        </div>
        <ul class="level-2">
            <li>
                <div class="wrapper">
                    <div class="random"><span class="glyphicon glyphicon-random"></span></div>
                    <div class="name">Toevoegen</div>
                </div>
            </li>
            <li>
                <div class="wrapper">
                    <div class="random"><span class="glyphicon glyphicon-random"></span></div>
                    <div class="name">Sorteren</div>
                </div>
            </li>
            <li>
                <div class="wrapper">
                    <div class="random"><span class="glyphicon glyphicon-random"></span></div>
                    <div class="name">Eigenschappen</div>
                </div>
            </li>
        </ul>
    </li>
</ul>


Iemand die mij kan vertellen hoe ik de data na het sorteren kan ophalen? Wat doe ik mogelijk verkeerd in m'n javascript "stop" fallback functie?
Sorry voor de bump, maar ik heb er voor de duidelijkheid een jsFiddle van proberen te maken. Ik krijg er de jquery, jquery ui en nestedSortable jammer genoeg niet echt netjes in verwerkt. Hopelijk schetst dit al iets duidelijker m'n probleem? ;)
Ik worstel nog altijd met ditzelfde probleem. De jsFiddle heb ik ondertussen werkend (en eenvoudiger) gekregen. Wanneer ik een verplaatsing van de elementen doe, probeer ik de array in de console te printen. Ik krijg echter de hele tijd een foutmelding dat ik niet snap:

Uncaught TypeError: Cannot read property 'match' of undefined

Ik begrijp deze foutmelding niet echt. Op de demo pagina van de nestedSortable plugin werkt alles goed, al wordt de array daar wel met een knop opgeroepen. Heeft er niemand ervaring met de nestedSortable plugin? :)

Reageren