I have a very simple element in my HTML:
<select multiple="multiple" size="19" name="Title[book_types_array][]" id="Title_book_types_array"> <option value="0">None Selected</option> <option value="1" selected="selected">Textbook School</option> <option value="2">Textbook Undergraduate</option> </select>
And I have a bit of jQuery that magically allows you to select one click:
$('select[multiple] option').click(function(e){ var self = $(this); e.preventDefault(); if (self.attr('selected')) self.removeAttr('selected'); else self.attr('selected', 'selected'); });
And it works just dandy in Firefox, but not in Chrome.
It technically works in Chrome, but does not update the item. As an example, I select two options, and then deselect them, it still shows them as selected. However, when I select a new option in an element, it now updates and deselects two elements that I have not selected previously. It will also update the item if I click on another window and then again.
Is this some kind of bug in Chrome with this element or is something missing?
Edit
When I look in the console, I see how it removes the selected attribute, it just does not refresh the element.
Added example: http://jsfiddle.net/Udf5c/
source share