select-picker icon indicating copy to clipboard operation
select-picker copied to clipboard

picker('get') returns select object when can't normally render options

Open eLFuvo opened this issue 6 years ago • 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.

https://jsfiddle.net/vu8t2j9h/

eLFuvo avatar Dec 17 '18 13:12 eLFuvo

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?

AuHau avatar Dec 17 '18 20:12 AuHau

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.

eLFuvo avatar Dec 20 '18 08:12 eLFuvo

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.

AuHau avatar Dec 28 '18 18:12 AuHau

How about this? https://github.com/eLFuvo/select-picker/commit/ca02d9f54cb0adde62ed44fb5c05fff31276f98d#diff-d3386db72668eb7dd21d95bd4d49c4d4R453

eLFuvo avatar Dec 30 '18 14:12 eLFuvo