Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple select in Safari iOS 7

Tags:

When I use the multiple option in a select dropdown - safari runs into weird issues. When I select an option and say Done, the dropdown goes back to showing '0 items'. But if I select multiple options (more than one), everything except the first one gets selected. After this, if I unselect all options, the last one remains selected.

Check this for a demo using safari on iOS 7.0.3.

<select multiple="multiple"> <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> </select> 

I've looked at http://www.thecssninja.com/html/optgroup-ios6, but that talks about issues with using optgroups - which(when used with multiple) currently seems to crash safari altogether.

like image 388
zacropetricopus Avatar asked Nov 18 '13 02:11

zacropetricopus


People also ask

How do I select multiple items in iOS?

Rather than using a sub-menu to put the items in “Select” mode and then ticking the circles that appear in each row, you can just swipe two fingers down the list to select every item in the list that your fingers touch.

How do I select multiple tabs in Safari iOS?

You should be able to do that by first selecting one of the tabs and start dragging it, you can then click the additional tabs you want and they will be added and grouped with the first tab.

How do you do multiple selections on iPad?

Selection tips To select multiple items, hold down Cmd or Shift when you click. Or, while in multi-select mode, click and drag downward on the dots to the right. To deselect something, just click in an open space.


2 Answers

    // hack for iPhone 7.0.3 multiselects bug     if(navigator.userAgent.match(/iPhone/i)) {         $('select[multiple]').each(function(){             var select = $(this).on({                 "focusout": function(){                     var values = select.val() || [];                     setTimeout(function(){                         select.val(values.length ? values : ['']).change();                     }, 1000);                 }             });             var firstOption = '<option value="" disabled="disabled"';             firstOption += (select.val() || []).length > 0 ? '' : ' selected="selected"';             firstOption += '>&laquo; Select ' + (select.attr('title') || 'Options') + ' &raquo;';             firstOption += '</option>';             select.prepend(firstOption);         });     } 
like image 74
Gromo Avatar answered Oct 04 '22 03:10

Gromo


Simple add:

<option disabled></option> 

as the first element of multiple select.

like image 36
Rodrigo Silva Avatar answered Oct 04 '22 02:10

Rodrigo Silva