1

I'm trying to disable all non valid options within a jquery select..... disabling specific options works fine, but when I want to re-enable them, they still stay disabled.... I've googled and tyried a lot to fix this issue, but non of my attempts work....

Following some more detailed expainations. I would be very very grateful for any help!

The jquery select with all options:

    <select id="opt_projects" class="f-dd">
        <optgroup label="Intern">
            <option value="1">Arbeitsbeginn</option>
            <option value="2">Pause Beginn</option>
            <option value="3">Pause Ende</option>
            <option value="4">Fahrzeit Start</option>
            <option value="5">Fahrzeit Stop</option>
            <option value="6">Feierabend</option>
        </optgroup>
        <optgroup label="Auftrag 123482">
            <option value="20">Instandhaltungsauftrag</option>
            <option value="21">Reparaturauftrag</option>
            <option value="22">Wartungsauftrag</option>
                <option value="23">Kalibirierungsauftrag</option>
            <option value="24">Serviceauftrag</option>
            <option value="25">Aufarbeitungsauftrag</option>
    </optgroup>
</select>

After clicking an specific button, these values aere shown within a mobiscroll select-scroller: enter image description here

After the user has choosen one Task (For example Arbeitsbegin [eng.: Start of work]) I want to disable this option. This works fine. But when I want to enable it again, this doesn't work. Following the code for the click-handler, the mobiscroll-scroller and the change function (which doesnt work....)

click-Handler:

//Click-Listener für den Projekt-Change-Button
     $('#btn_changeProject').click(function () {
     myLogger("Project-Change-Button wurde geklickt");
     $('#opt_projects').mobiscroll('show');
     return false;
});

Mobiscroll-Scroller:

    // Initialisieren und anhängen des scroller
 $('#opt_projects').mobiscroll().select({
        theme: 'android-ics',
        group: true,
        lang: 'de',
        display: 'bottom',
        mode: 'clickpick',
        inputClass: 'i-txt',
        label: 'Vorgangsart',
        groupLabel: 'Auftrag',
        headerText: function(value) {
                return 'Gewählte Vorgangsart: ' + value;
        },
        // Nachdem ein Element selektiert wurde
        onSelect: function(valueText, inst) {
            // und alle Labels neu erzeugt
            myLogger("Neues Projekt wurde selektiert");
            changeLabels(valueText);
        }
    });

and the not working change function (this function is called by the onSelect-callback function of the mobiscroll-scroller)

 // Validierungen für die Optionsliste
function validateOptions()  {
var update_options = function () {
    if ($('#opt_projects option[value="3"]').prop('disabled'))  {
        // none of this work......
        $('#opt_projects option[value="3"]').prop('disabled', false);
 //         $('#opt_projects option[value="3"]').removeAttr('disabled').change();
 //         $('#opt_projects option[value="3"]').removeAttr('disabled');
 //         $('#opt_projects option:eq(2)').prop('disabled', false);
 //         $('#opt_projects option:eq(2)').removeAttr('disabled');
    } else {
        // Works fine..........
        $('#opt_projects option[value="3"]').prop('disabled', true);
        }
     };
     $(update_options);
     $("#opt_projects").change(update_options);
//   $("#opt_projects").trigger("refresh");
//   $('#opt_projects').trigger('change');
}

It would be great, when enyone could help me with this issue.... Thanks, Daniel

Daniel Rausch
  • 215
  • 4
  • 12
  • Update: Using firebug shows, that the options are disabled and are getting re-enabled by the code shown above.... unfortunately the mobiscroll scroller didn't notice that (it notice only the disabling options....) any help wouöd be a dream! – Daniel Rausch May 30 '13 at 12:22

1 Answers1

0

You can re-enable all select options with

$('#opt_projects').find("option").each(function() {
    $(this).attr("disabled", false);
    $('#opt_projects').selectmenu("refresh", true); 
});

or just the option with value = 3 with

$('#opt_projects').find("option").each(function() {
    if($(this).val()== "3" ){
        $(this).attr("disabled", false);
        $('#opt_projects').selectmenu("refresh", true); 
    }
});
eggdeng
  • 148
  • 9