bind.js icon indicating copy to clipboard operation
bind.js copied to clipboard

Bind <Select>

Open DCSDB opened this issue 8 years ago • 5 comments

I am trying to bind the values of an array to the input values of a select, similar to how you bind "cats" to a UL in the playground. If I assign the array to a UL with the function :

dom:'#cats', transform: function (item){return "";}

and #cats is a UL, the the values are printed.

If I change #cats to a SELECT I get no love. any ideas?

Thank you

DCSDB avatar Dec 14 '15 14:12 DCSDB

Can you paste up the code that you're using?

remy avatar Dec 14 '15 15:12 remy

Sure : https://jsbin.com/xinadegesa/edit?html,js,console,output

change "" to "

    " and you will see the list render correctly.

    Cheers.

    DCSDB avatar Dec 14 '15 18:12 DCSDB

    I think the transform should actually contain the following (since it receives the updated array, and doesn't fire for each element):

    transform: function (cat) {
      return cat.map(_ => `<option>${_.name}</option>`);
    }
    

    But this still doesn't update, so I need to investigate a little further.

    remy avatar Dec 14 '15 22:12 remy

    Would appreciate input on this: https://github.com/remy/bind.js/issues/23

    remy avatar Feb 01 '16 17:02 remy

    Change this: "var valueSetters = ['SELECT', 'INPUT', 'PROGRESS', 'TEXTAREA'];" TO var valueSetters = ['OPTION', 'INPUT', 'PROGRESS', 'TEXTAREA'];

    raminasri avatar Mar 30 '16 00:03 raminasri