Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
Onsen UI 2 problem with select
-
Hi :)
I’m using Onsen UI 2.0
I load with $.get a JSON list and then I build a HTML string with all options, then I attach the string in this way:
$("#mySelect").html(html);
This is done in the show event.
The problem is that doesn’t work. If I use normal select, it works. If I use ons-select, on Chrome I see all options like text surrounded by <p>, in OS X I don’t see anything.
Can you help me?
Thank you
-
@marco3189 Well, you are removing all the previous innerHTML. There was supposed to be a native select inside the
ons-select
but I guess it’s gone after you set the innerHTML :sweat_smile:
If you really want to use innerHTML, try to get the$("#mySelect select")
instead.By the way, that was super fast, we just released
ons-select
. We are open to suggestions about it :)
-
@misterjunio This is one of the problems with the DOM manipulation, it can be unexpected. Perhaps we should force to write a
select
inside or at least provide a way to se its ID withinput-id
attribute…
-
@Fran-Diox THank you :) I will try tomorrow and I’ll let you know. One suggestion would be the thing that I’m trying to do: a function that permit to modify the options collection of the select.
-
@marco3189 We are adding a
select-id
attribute so that the inner select element can be accessed dynamically, thanks again for your input :+1:
-
Thank you :) I’ve tried to as @Fran-Diox suggested but it doesn’t work. Is there a preview channel where I can try this fix? :)
-
@marco3189 The code is already in our
vue2
branch on GitHub but we haven’t published yet. Should happen soon though.