Removing items from a drop down
Removing items from a drop down
I have removed items from a drop down using the code below, just wondering instead of listing each option, is there a way of saying hide all values above 3?
I could not just just use a WHERE on the controller because I want people to see the status when it is above 3, just not be able to set it to anything above 3.
Thoughts?
editor.dependent('A.assetStatus', function(val, data, callback) {
if (val > 3) {
editor.disable('A.assetStatus');
} else {
editor.enable('A.assetStatus');
$('#DTE_Field_A-assetStatus').find('option[value="4"]').hide();
$('#DTE_Field_A-assetStatus').find('option[value="5"]').hide();
$('#DTE_Field_A-assetStatus').find('option[value="6"]').hide();
$('#DTE_Field_A-assetStatus').find('option[value="7"]').hide();
$('#DTE_Field_A-assetStatus').find('option[value="8"]').hide();
$('#DTE_Field_A-assetStatus').find('option[value="9"]').hide();
$('#DTE_Field_A-assetStatus').find('option[value="10"]').hide();
$('#DTE_Field_A-assetStatus').find('option[value="11"]').hide();
}
callback(true);
});
This question has an accepted answers - jump to answer
Answers
jQuery's
filter
is probably the best way to do it:Allan
Thanks Allan
Interesting, I thought this worked, but it didn't after all.
I assumed what you have put goes into the else side of the if statement after the editor.enable('A.assetStatus'); but it didn't work.
Am I missing something Allan?
Nothing obvious that I can see! Perhaps you can give me a link to a page showing the issue? This is when the Editor form is shown? If it is hidden you would need to use
field().input()
to get theselect
element (which is probably a good idea anyway).Allan