There is a way,plugin or code snippet that i could use to make
<select><option disable="disable">....</option></select>
options in safari on ipad to be disabled ?
latter edit: here is the code:
function getSelectedValues(ids) {
var selectedValues = []
, $selected = $('.selector').children('option:selected');
$selected.each(function(){
if(this.value != 0){
if(ids == true){
selectedValues.push(this.value+'-'+$(this).parent().attr('id'));
} else {
selectedValues.push(this.value);
}
}
});
return selectedValues;
}
function clearDisabled() {
$('.selector').children(':disabled').attr('disabled', false);
}
function disableSelected(selectedValues,id) {
sv = selectedValues || [];
if(id === true){
var selectedIds = [];
var selectedVals = [];
$.each(selectedValues, function(key, value) {
values = value.split('-');
selectedVals.push(values[0]);
selectedIds.push(values[1]);
});
for (var i=0;i<selectedVals.length;i++) {
$('.selector').each(function(){
if($(this).attr('id') == selectedIds[i]){
$('option[value=' + selectedVals[i] + ']',this).not(':selected').attr('disabled', true);
}
});
}
}
}
$(document).ready(function(){
$('.selector').change(function(){
selectedValues = getSelectedValues(true);
clearDisabled();
disableSelected(selectedValues, true);
});
var selectedValues = getSelectedValues(true);
disableSelected(selectedValues, true);
});
I did some digging and i realize that this is a limitation of safari mobile...
It is more complicated to get a cross browser implementation, safari for iPad and iPhone, ie6 and I presume some other browser just ignore the disabled options.
You need to remove them. So, keep a copy of it and rebuild the options whenever you want.
This is an example where you can enable/disable options based on their value
or if you are using jquery 1.6 or higher