picker('get') returns select object when can't normally render options
eLFuvo opened this issue · 4 comments
When I try to render empty select by plugin it doesn't make anything - it's ok;
But when I try to get the value of this select using the plugin, I get the select node instead of an empty (e.g. null) value.
Thanks for the report!
I believe the problem is in the "empty select".
As you can see here: https://github.com/AuHau/select-picker/blob/master/src/picker.js#L65
It is currently not possible to create picker instance with select that does not have any options (the initialization is aborted and error printed to console).
What are you trying to achieve?
I have wrote in previous comment - I have expect empty/undefined/null value from api_get function
As you can see in example https://jsfiddle.net/vu8t2j9h/4/ value of select is returning normaly by jQuery.
To be honest, not sure if that is possible with the current approach I use for the "API" style calls. API calls depend on the Picker to be correctly initialized which is not happening because it does not support empty selects.
But I agree that the behavior you described would make more sense, unfortunately, I don't really see any easy way to accomplish it and I don't have time right now to do any major work on this.
If you have ideas on how to solve it, PR will be welcomed.
PS.: Just to direct you where is the problem, it lays between lines 455-463.
How about this?
eLFuvo@ca02d9f#diff-d3386db72668eb7dd21d95bd4d49c4d4R453