• Resolved cannect

    (@cannect)


    Hi,

    I recently found a bug in your plugin, I have a multiselect which starts with numbers. They are ordered in natural order. e.g.:

    1
    11
    120
    2
    25
    270
    3
    33

    This is unexpected behavior I think.

    Because I only use the choosen multi select types, I altered one function:

    function woof_init_mselects() {
        try {
    
            jQuery("select.woof_mselect").each(function(select){
                var select = jQuery(this);
                var options = select.find('option');
    
                options.sort(function(a,b) {
    
                    if ( !isNaN(parseInt(a.text[0])) ) {
                        a = a.text.replace(/[^[0-9]!?]/g,'');
                        b = b.text.replace(/[^[0-9]!?]/g,'');
                        if (parseInt(a) > parseInt(b)) return 1;
                        else if (parseInt(a) < parseInt(b)) return -1;
                        else return 0
                    }
                    if (a.text > b.text) return 1;
                    else if (a.text < b.text) return -1;
                    else return 0
                });
                select.empty().append(options);
            });
    
            // jQuery("select.woof_select").chosen('destroy').trigger("liszt:updated");
            jQuery("select.woof_mselect").chosen(/*{disable_search_threshold: 10}*/);
        } catch (e) {
    
        }

    Can you please fix it for all list types in your code?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello

    This functionality does not apply to plug-in.

    Reason: for WordPress all taxonomies tiles and slugs is just STRINGS so WOOF works with them as string, and appending idea to them that they are numbers is just human logic, but not for script

    This trouble was always, and can be resolved by drag and drop on the terms page:
    Example
    * go here wp-admin/edit-tags.php?taxonomy=pa_shoe-size&post_type=product
    * by mouse set right order of terms

    Thread Starter cannect

    (@cannect)

    Aha! Thats indeed the logical way of doing it. Never thought about that.

    Many thanks!

    Hello

    Welcome;)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bug: sorting of number items in natural order’ is closed to new replies.