rvera / image-picker

Image Picker is a simple jQuery plugin that transforms a select element into a more user friendly graphical interface.
http://rvera.github.com/image-picker
Other
906 stars 216 forks source link

Disabled select doesn't show selected value #46

Open juhah opened 9 years ago

juhah commented 9 years ago

Hi,

And thanks for a nice plugin :) I noticed that a disabled select doesn't show the selected value (due to .val() returning null if the select is disabled, see: http://bugs.jquery.com/ticket/13097).

I could get this to work by replacing this line in ImagePickerOption.prototype.is_selected():

var select_value;
select_value = this.picker.select.val();

with:

var select_value, selected_index;
selected_index = this.picker.select.prop('selectedIndex');
select_value = this.picker.picker_options[selected_index].value();

Also it would be nice to get an additional class to the wrapper if select is disabled. What do you think?

Juha

rvera commented 9 years ago

Super late reply, this sounds good. Would you mind creating a PR for this?

juhah commented 9 years ago

Pull request created: https://github.com/rvera/image-picker/pull/55