Ok, I did it. Was not sure if I would manage ??
Could you incorporate that into your plugin? That would be great. Thanks,
Sascha
Here is the code:
1. Add another button to your form:
<input type="submit" name="order-alpha" id="order-alpha" class="button-primary" value="<?php _e('Sort Alphabetical', 'customtaxorder') ?>" />
2. Add some jQuery stuff into your script:
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(function(jQuery) {
jQuery("#custom-loading").hide();
jQuery("#order-submit").click(function() {
orderSubmit();
});
jQuery("#order-alpha").click(function(e) {
e.preventDefault();
jQuery("#custom-loading").show();
orderAlpha();
//jQuery("#order-submit").trigger("click");
setTimeout(function(){
jQuery("#custom-loading").hide();
},500);
jQuery("#order-alpha").blur();
});
});
function customtaxorderAddLoadEvent(){
jQuery("#custom-order-list").sortable({
placeholder: "sortable-placeholder",
revert: false,
tolerance: "pointer"
});
};
addLoadEvent(customtaxorderAddLoadEvent);
function orderSubmit() {
var newOrder = jQuery("#custom-order-list").sortable("toArray");
jQuery("#custom-loading").show();
jQuery("#hidden-custom-order").val(newOrder);
return true;
}
function orderAlpha() {
jQuery("#custom-order-list li").sort(asc_sort).appendTo('#custom-order-list');
var newOrder = jQuery("#custom-order-list").sortable("toArray");
jQuery("#custom-loading").show();
jQuery("#hidden-custom-order").val(newOrder);
return true;
}
// accending sort
function asc_sort(a, b){
//return (jQuery(b).text()) < (jQuery(a).text()) ? 1 : -1;
//console.log (jQuery(a).text());
return jQuery(a).text().toUpperCase().localeCompare(jQuery(b).text().toUpperCase());
}
// ]]>
</script>