Jump to content
MakeWebGames

Recommended Posts

Posted

I have used the jQuery UI's sortable boxes element but i cannot work out how to save the positions of the boxes, currently i have this JS which is used to initiate the boxes.

$(function() {

$(".leftColumn, .rightColumn").sortable({

containment: "window",

cursor: "crosshair",

connectWith: ".comumns"

}).disableSelection();

});

The documentation shows there is an update event with this but im not sure how exactly i can do this.

Link to jQueryUI documentation:

http://jqueryui.com/demos/sortable/#event-change

Posted

Re: jQueryUI sortable boxes

I made an example that might be helpful to you: http://www.steelbreeze.us/play_ground/o ... es/pg.html

Specifically, I've added in a "change" event handler to your code:

 

		$(function() {
	$(".leftColumn, .rightColumn").sortable({
		containment: "parent",
		cursor: "crosshair",

		// CHANGE EVENT STARTS HERE
		change: function(event, ui) {

			// CREATE DEBUG OUTPUT
			var output = document.createElement('p');
			document.body.appendChild(output);
			output.style.width = '600px';
			output.style.margin = '0 auto';
			for (var x in event) {
				output.innerHTML += event[x];
			}
			output.innerHTML += '
-----------------------------------------
';
			for (var y in ui) {
				output.innerHTML += ui[y];
				for (var z in y) {
					output.innerHTML += y[z];
				}
			}
			output.innerHTML += '
-----------------------------------------
';
			// END OF CREATE DEBUG OUTPUT
		}
		// END OF CHANGE EVENT

	}).disableSelection();
});

 

Hope that helps...

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.   Paste as plain text instead

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