mercredi 25 mai 2016

Disabling select option with specific value in Ember

I am using Ember 1.4 and I am having an issue getting a select element(attempt_interval) to be disabled when another select element(max_attempt_count) has a value of 1. It works fine when in my testing environment when not using Ember. Any ideas?

jQuery

$(document).on('change', 'select[name=max_attempt_count]', function(){

    var ctrl=$(this);//$(this) refers to current clicked button
    var maxAttempt =ctrl.closest('form').find('select[name=max_attempt_count]');
    var interval =ctrl.closest('form').find('select[name=attempt_interval]');

    $(maxAttempt).change(function() { //each time a user selects a option (event triggered)
        $(interval).prop('disabled', this.value == 1);
    }).change(); //auto execute when page load
} )

HTML

<select id="ember894" class="ember-view ember-select chosen-select" name="max_attempt_count" style="display: none;">
 <option id="ember907" class="ember-view" value="1">
 <option id="ember908" class="ember-view" value="2"><option id="ember909" class="ember-view" value="3">
 <option id="ember910" class="ember-view" value="4">
 <option id="ember911" class="ember-view" value="5">
</select>




Aucun commentaire:

Enregistrer un commentaire