-
const Options = ({ label, options, setting }) => {
return div({
class: 'dark blurry',
style: 'pointer-events:all;min-height:100%;flex-direction:row;min-width:max-content;gap:1rem;border-radius:.5rem;box-sizing:border-box;margin:.1rem',
onclick: (e) => { e.stopPropagation() }
},
div({ class: 'f2 cJ', style: 'padding:1rem;width:min-content;' }, label),
select(
{
style: 'margin:.5rem;box-sizing:border-box',
oninput: e => { setting.val = e.target.value; prnt('setting', setting.val, exportOptions) },
},
options.map(c => option({ value: c, selected: c == setting }, c))
),
)
}
const Export = () => {
return div({ style: 'flex-direction:row;' },
Options({ label: 'Size Mult', options: [0.25, 0.5, 1, 1.5, 2, 3], setting: vanX.stateFields(exportOptions).multiplier }), Hi, I'm trying to make an options selecter, passing in a vanX.reative object as setting (exportOptions) This prints the correct values (setting.val) but exportOptions object is not updated. Is there a way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
For |
Beta Was this translation helpful? Give feedback.
-
Also you need to wrap |
Beta Was this translation helpful? Give feedback.
-
const exportOptions = vanX.reactive({
width: 1920,
height: 1920,
multiplier: 1,
imageType: 'png',
}) options.map(c => option({ value: c, selected: () => (c == setting.val) }, c))
this prints info! 2 Proxy(Object) {width: 1920, height: 1920, multiplier: 1, imageType: 'png', Symbol(): {…}, …} I'm confused because setting.val looks correct, but exportOptions is unchanged (multiplier should be 2) |
Beta Was this translation helpful? Give feedback.
-
Ah, that was it. Works correctly now. Is console updated afterwards? |
Beta Was this translation helpful? Give feedback.
-
Hi @HEAVYPOLY, VanX |
Beta Was this translation helpful? Give feedback.
For
option({ value: c, selected: c == setting }, c)
, shouldsetting
besetting.val
?