Created
April 9, 2015 04:06
-
-
Save musicalbigfoot/bbabae80cefc8d0ae9e8 to your computer and use it in GitHub Desktop.
ACF: Update repeater field sort order jquery/ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#my-library').sortable({ | |
// containment: "parent", | |
items: "> li.set-item", | |
update: function(e, ui){ | |
console.log('UPDATE'); | |
var new_order = $(this).sortable('toArray'); | |
updateSortOrder(new_order); | |
} | |
}); | |
function updateSortOrder(new_order) { | |
console.log("Updating sort order..."); | |
var postdata = { | |
action: 'library_set_update_sort', | |
new_order: new_order | |
}; | |
jQuery.ajax({ | |
type: "POST", | |
url: "/wp-admin/admin-ajax.php", | |
dataType: 'json', | |
data: postdata, | |
success: function(data){ | |
console.log(data); | |
}, | |
error: function(data){ | |
console.log("ERROR"); | |
console.log(data); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment