From 98fb6e45d7c0ce9b7e270160bd028d7ab7340fdc Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Wed, 5 Dec 2012 09:04:19 +0000 Subject: [PATCH] Use data on the ui.item to transport the original Sortable index for the update() function. This way extensions can set/access this info in their own custom Sortable functions. see #22696 git-svn-id: http://core.svn.wordpress.org/trunk@23067 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-views.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index de7f745154..3d90fc223f 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -3180,8 +3180,7 @@ }, initSortable: function() { - var collection = this.collection, - from; + var collection = this.collection; if ( ! this.options.sortable || ! $.fn.sortable ) return; @@ -3200,13 +3199,13 @@ // Record the initial `index` of the dragged model. start: function( event, ui ) { - from = ui.item.index(); + ui.item.data('sortableIndexStart', ui.item.index()); }, // Update the model's index in the collection. // Do so silently, as the view is already accurate. update: function( event, ui ) { - var model = collection.at( from ), + var model = collection.at( ui.item.data('sortableIndexStart') ), comparator = collection.comparator; // Temporarily disable the comparator to prevent `add`