Where to find the select2 plugin?

Where to find the select2 plugin?

rudirudi Posts: 8Questions: 1Answers: 0

Hi Alan,
Where can I find the select2 plugin? On the related page both links are pointing to the GitHub select2 page.
Best regards
Rudi

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,179Questions: 1Answers: 10,410 Site admin

    As in the Select2 plug-in for Editor? It is available here. The Editor plug-ins page lists all available plug-ins.

    Allan

  • rudirudi Posts: 8Questions: 1Answers: 0

    Hi Allan,
    again thanks for your very fast response.
    I already downloaded select2.js and select2.css but how can I use it with the editor?
    If I assign the type select2 to a field, I get the error, that select2 is an unknown type.
    I browsed through the forum and found a reference to editor.select2.js, but wasn't able to find this wrapper.

  • allanallan Posts: 63,179Questions: 1Answers: 10,410 Site admin
    edited March 2016

    Did you download the Select2 / Editor plug-in from the link I gave above?

    edit I see you don't have an Editor license. The plug-ins are currently only available to license holders (which should be noted in the link above).

    Allan

  • rudirudi Posts: 8Questions: 1Answers: 0

    Hi Alan, I have purchased an Editor license on Oct., 26, 2015.

  • rudirudi Posts: 8Questions: 1Answers: 0

    Hi Allan,
    the payment was done via PayPal Transaction-ID: 78B208913H256781L, because there was a problem with the payment on your Web-Page.
    Please check.

    Best regards
    Rudi

  • allanallan Posts: 63,179Questions: 1Answers: 10,410 Site admin
    Answer ✓

    Thanks for the clarification. It looks like the license was purchased from a different account name: Rudi_Schloesser. If you logout and then log back in with that account you'll have access to the latest Editor downloads and the plug-ins.

    Allan

  • rudirudi Posts: 8Questions: 1Answers: 0

    Hi Allan,
    I wasn't aware of this account. Got the plugin now and it works like a smart.
    Many thanks, Rudi

  • rudirudi Posts: 8Questions: 1Answers: 0

    Hi Allan,
    I'm trying to use the select2 instead of a couple of checkboxes (with separator set to ',').
    Now, with the select2 plugin the Ajax request doesn't contain an array like data[#][perm] = [x,y,z], but multiple data[#][perm][] = x, data[#][perm][] = y, ...
    How to force the editor to return the select2 value as an array?

    Best regards
    Rudi

  • allanallan Posts: 63,179Questions: 1Answers: 10,410 Site admin

    That's the parameter's submitted to the server?

    That form is how an array is represented with HTTP parameters. If you use preSubmit to inspect the data, you should be able to see that perm is an array.

    Allan

  • rudirudi Posts: 8Questions: 1Answers: 0

    Hi Allan,
    just figured it out.

    First I added the separator to the field definition.
    Next I changed the get-Method in the plug-in to

        get: function ( conf ) {
            var val = conf._input.val();
    
            if (conf._input.prop('multiple')) {
                if ( conf.separator ) {
                    return val.join( conf.separator );
                } else if ( val === null ) {
                    return [];
                }
                return val;
            }
            return val;
        },
    

    which gives me the desired result.

  • rudirudi Posts: 8Questions: 1Answers: 0

    Hi Allan,
    just some improvement, if the select2 is empty (no initial value):

        get: function ( conf ) {
            var val = conf._input.val();
    
            if (conf._input.prop('multiple')) {
                if ((val != null) && (val.length > 0)) {
                    if ( conf.separator ) {
                        return val.join( conf.separator );
                    } else {
                        return val;
                    }
                } else {
                    return [];
                }
                return val;
            }
            return val;
        },
    
    
  • allanallan Posts: 63,179Questions: 1Answers: 10,410 Site admin

    Super - thanks for the feedback. I'll look at incorporating that, and good to hear you've got it working.

    Allan

This discussion has been closed.