Select2 disable not working...

Select2 disable not working...

kaustubh.agrawal2000kaustubh.agrawal2000 Posts: 81Questions: 35Answers: 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 ) {

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 ?

Steps to reproduce

  - UNAME:
  - PWD : 12345678
Clear browser cache
TRY Editing any of the rows..
The commodity field is disabled but still the select options are shown and selectable.


This question has an accepted answers - jump to answer


  • allanallan Posts: 48,698Questions: 1Answers: 7,081 Site admin
    Answer ✓

    You have this in common.js which is causing the list to open:

    $(document).on('focus', '.select2.select2-container', function (e) {
        // only open on original attempt - close focus event should not fire open
        if (e.originalEvent && $(this).find(".select2-selection--single").length > 0) {


  • kaustubh.agrawal2000kaustubh.agrawal2000 Posts: 81Questions: 35Answers: 2

    Thanks a lot Allan..
    You are awesome...

    BTW, can you please let me know, what tools do you use to debug JS ?
    I find it particularly difficult to track JS events....

Sign In or Register to comment.