I fiddled with nested riot tags and tried to pass options from one field to nested fields.
simplified example:
field options:
{
"display_field" : "colors",
"values": ["#111111","#cccccc","#ffffff","#00ff00"]
}
field-custom.tag:
<field-custom>
<cp-field type="tags" if="{ opts.display_field == 'tags' }" opts="{ {autocomplete:values} }" bind="{ opts.bind }"></cp-field>
<cp-field type="colortag" if="{ opts.display_field == 'colortag' }" opts="{ {colors:values} }" bind="{ opts.bind }"></cp-field>
<div if="{ !opts.display_field }">
<ul>
<li each="{ option in opts.values }">
{ option }
</li>
</ul
</div>
</field-custom>
Actually, I try to modify the RequestSelectOptions addon to reuse the core fields for custom visual select styles.
The problem is, that some fields have different mechanisms to load their options. Some load it on mount
, some on update
and others don’t mount or update and use the opts directly.
If all the fields would load consistent, it would be easier to reuse them when customizing the backend or writing custom field addons. Also a few core views and fields could benefit from it.
I wrote a fix for tags and colortag fields and I try to write some more, but sometimes it’s hard to understand the Uikit/riot.js/jQuery/Utils mixup… and I don’t want to break anything by accident.
A few things, I don’t understand:
var $this = this;
Some fields work without this line.
this.mixin(RiotBindMixin);
This line is in the views and in cp-assets.tag
, but I don’t understand, what it is used for.
edit: Got it. It’s for @lang()
instead of App.i18n.get()
etc.
this.$initBind = function() { this.root.$value = this.selected; };
It doesn’t seem to have any effect.
@artur Can you give some hints, please?