I have a dropdown-menu with a couple options. I want to loop through them and prop the disabled
attribute on some of them base its result from the Ajax call.
This what I'm trying to achieve.
Sample Reportable Data
s-00591 | true
s-00592 | false
s-00593 | false
s-00594 | false
s-00595 | false
HTML
<select class="rn-dropdown" id="rn-dd">
<option value="class-view">class view</option>
<!-- Students Populate Here -->
<option value="s-00591">Student S00591</option>
<option value="s-00592">Student S00592</option>
<option value="s-00593">Student S00593</option>
<option value="s-00594">Student S00594</option>
<option value="s-00595">Student S00595</option>
</select>
JS
success: function(reportable) {
$.each(reportable , function(i, v) {
var userId = v.userId;
var reportable = v.reportable;
var currentVal = userId;
console.log('start');
console.log(userId + " | " +reportable);
$('#rn-dd option[value="' + currentVal + '"]').prop('disabled', true);
console.log('end');
});
}
Result,
I got no error displaying the console. But I keep seeing my dropdown-menu is not disabled as I want them to.
Any hints / helps / suggestions will mean a lot to me.