From 867f5fc769c88728da9586729ddb0040e9677310 Mon Sep 17 00:00:00 2001 From: treygeorge Date: Fri, 13 Sep 2013 19:19:02 -0500 Subject: [PATCH 1/2] Add data- attributes to the output object. Trying to make the final object output a little bit more useful by allowing the developer to define any data- attribute and have it added to the final object. --- jquery.mjs.nestedSortable.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jquery.mjs.nestedSortable.js b/jquery.mjs.nestedSortable.js index e6c0d62..ada5a68 100644 --- a/jquery.mjs.nestedSortable.js +++ b/jquery.mjs.nestedSortable.js @@ -283,9 +283,17 @@ return ret; function _recursiveItems(item) { + var dataItems = []; + $(item).data().each(function(index, value) { + dataItems[index] = value; + }); + var id = ($(item).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); if (id) { var currentItem = {"id" : id[2]}; + $.each(dataItems, function(index, value) { + currentItem[index] = value; + }); if ($(item).children(o.listType).children(o.items).length > 0) { currentItem.children = []; $(item).children(o.listType).children(o.items).each(function() { From 15296944e7368d482a1f2ab7791718c9b2e78c04 Mon Sep 17 00:00:00 2001 From: treygeorge Date: Sat, 14 Sep 2013 12:05:33 -0500 Subject: [PATCH 2/2] Fixing control. Formatting clean up. Removed the jquery each and opted for JS for instead. Also, some minor formatting polish. --- jquery.mjs.nestedSortable.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jquery.mjs.nestedSortable.js b/jquery.mjs.nestedSortable.js index ada5a68..536999e 100644 --- a/jquery.mjs.nestedSortable.js +++ b/jquery.mjs.nestedSortable.js @@ -284,6 +284,7 @@ function _recursiveItems(item) { var dataItems = []; + $(item).data().each(function(index, value) { dataItems[index] = value; }); @@ -291,9 +292,11 @@ var id = ($(item).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); if (id) { var currentItem = {"id" : id[2]}; - $.each(dataItems, function(index, value) { - currentItem[index] = value; - }); + + for(var prop in dataItems) { + currentItem[prop] = dataItems[prop] + } + if ($(item).children(o.listType).children(o.items).length > 0) { currentItem.children = []; $(item).children(o.listType).children(o.items).each(function() {