Select2 Disable is not working as expected...

Select2 Disable is not working as expected...

kaustubh.agrawal2000kaustubh.agrawal2000 Posts: 88Questions: 39Answers: 2

I am using select2 plugin, although it works well, I have a use case where i should disable option select during edits.
which I am doing like:

editor.on( 'initEdit', function ( e, json, data ) {
        editor.disable('commodity_id');
        editor.disable('transaction_type');
});

Here, commodity_id & transaction_type are both select2 fields.. values of which are populated by AJAX.

The fields on the form are shown as GREYED OUT (like disabled).. but I am still able to select the options...

How can I disable that ?

Regards
Kaustubh

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Hi,

    I've just tried that locally and it appears to work as expected. Could you check that the version of the Select2 plug-in for Editor has:

        disable: function ( conf ) {
            $(conf._input).attr( 'disabled', 'disabled' );
        },
    

    in it, and also that you are using an up to date version of Select2 please?

    If that doesn't resolve it, please link to a test case showing the issue.

    Thanks,
    Allan

  • kaustubh.agrawal2000kaustubh.agrawal2000 Posts: 88Questions: 39Answers: 2

    Hi Allan..
    The issue is still not resolved... Please find the details as below

    GOTO: https://gadhiya.in
    Login
      - UNAME: sunil.gadhiya@gmail.com
      - PWD : 12345678
    
    Clear browser cache
    GOTO: https://gadhiya.in/parameter
    TRY Editing any of the rows..
    The commodity field is disabled but still the select options are shown and selectable.
    

    Code details

    Datatables: https://gadhiya.in/web/js/builder/datatables.min.js
    Select2 : https://gadhiya.in/web/js/builder/select2.min.js
    Plugin code: https://gadhiya.in/web/js/builder/custom.plugin.js

    Kindly let me know what to change...

    Thanks..

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Can you update your Select2 version please? You are using 4.0.2 at the moment, they have a 4.0.6-rc.1 available (or 4.0.5 for the last stable).

    Thanks,
    Allan

  • kaustubh.agrawal2000kaustubh.agrawal2000 Posts: 88Questions: 39Answers: 2

    Hi Allan..
    I have updated the select2 lib. but still same thing is happening...

    Please have a look at the websit I mentioned.

    Any help would be greatly appriciated.

  • kaustubh.agrawal2000kaustubh.agrawal2000 Posts: 88Questions: 39Answers: 2

    @allan any updates on this one... ??

This discussion has been closed.