Admittedly silly-seeming question... And...
before anyone hastily replies, "RTFM," I have yet I still don't quite grok it -- data-binding.So, I've got a sort of form, which is really a component consisting of inputs and whatnot and also a core-localstorage
element. I've successfully persisted the values of other inputs between sessions, yet I've gotten fuzzy on the paper-dropdown-menu
. gridlocked...
What I want to do is use the label
for the display value, and when the machine in machines
bit is going, I want the selected paper-item
to reflect the value from local storage (the label)
Oh, and this is in jade, btw. Here's how it's looking:
//- JADE
/** Stuff that works: **/
core-localstorage(id='storage', name='vbms-user-settings', value='{{settings}}')
.subhead General
paper-input(floatingLabel, label='Username', inputValue='{{settings.username}}', on-change='{{updateStorage}}')
paper-input(floatingLabel, label='Password', inputValue='{{settings.password}}', on-change='{{updateStorage}}', type='password')
paper-checkbox#vpn_gui_toggle.accent(label='Run Headless', checked, style='margin-right: 16px;')
/** The confusing input **/
paper-dropdown-menu#vm_dropdown(valueattr='label', on-core-select='{{updateDefaultVM}}')
template(repeat="{{machine in machines}}")
paper-item(label="{{machine.name}}")
Here's some js... this works fine; i'm trying to do things the "dogmatic" Polymer way.
/*\ JS
|*| ...blah blah polymer jank...
\*/
objectToStorage: function(obj) {
this.$.storage.value=obj;
this.$.storage.save();
},
updateStorage: function() {
this.objectToStorage(this.settings);
},
updateDefaultVM: function() {}
Can anyone lead me to the most-probably simple solution to this hangup?!
Thanks in advance!
I believe that the recommended way of using
<paper-dropdown-menu>
is to have a two layers of containers between it and the<paper-item>
s, based on the example from the current docs.If you're using that setup, you've now got a
<core-menu>
, which inherits from<core-selector>
. Things that inherit from<core-selector>
can make use of theselected
attribute to control which item is selected. But<core-selected>
defaults to checking to see if any of the items it contains has aname
attribute whose value matches theselected
value, so we also need to add inname
attributes to all of the<paper-item>
s.The end result of something simple, that doesn't rely on loading in values from
<core-localstorage>
, looks like the following. You should be able to do something similar if you're loading in the initial value from<core-localstorage>
instead of hardcoding it.