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


  • Onsen UI

    @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 :)


  • Onsen UI

    @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 with input-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.


  • Onsen UI

    @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? :)


  • Onsen UI

    @marco3189 The code is already in our vue2 branch on GitHub but we haven’t published yet. Should happen soon though.


Log in to reply