Jinntec / Fore

Fore - declarative user interfaces in plain HTML
MIT License
80 stars 11 forks source link

fx-insert into empty parent #226

Closed wolfgangmm closed 10 months ago

wolfgangmm commented 11 months ago

The way fx-insert seems to be defined now, it is not possible to insert a first child element into an empty parent, e.g.:

<fx-control ref="instance('vars')/geography-term" value-prop="checked" update-event="input">
  <label for="geographyTerm"><pb-i18n key="form.geography">Geographie / Topographie</pb-i18n></label>
  <input id="geographyTerm" type="checkbox" class="widget"/>
  <fx-insert event="value-changed"
    if="context()/text()='true'"
    ref="instance()//textClass/keywords[@scheme='https://edh.ub.uni-heidelberg.de/edep/terms']/term"
    origin="instance('templates')/term[@ref='#geography']"></fx-insert>
</fx-control>

only works if @ref points to an existing term, so we need at least one as placeholder. However, the list of terms in keywords will initially be empty.

JoernT commented 11 months ago

This can be done by using the 'context' attribute pointing to the parent and the 'ref' pointing to the child.

Example: https://jinntec.github.io/Fore/demo/insert2.html

to test:

For your example try this:

<fx-insert event="value-changed" if="context()/text()='true'" context="instance()//textClass/keywords[@scheme='https://edh.ub.uni-heidelberg.de/edep/terms']" ref="term" origin="instance('templates')/term[@ref='#geography']"

Wolfgang Meier @.***> schrieb am Do., 10. Aug. 2023, 13:07:

The way fx-insert seems to be defined now, it is not possible to insert a first child element into an empty parent, e.g.:

only works if @ref points to an existing term, so we need at least one as placeholder. However, the list of terms in keywords will initially be empty.

— Reply to this email directly, view it on GitHub https://github.com/Jinntec/Fore/issues/226, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADWFW3JIQFZ3DHFKXNBEF3XUS6GRANCNFSM6AAAAAA3LKPYIU . You are receiving this because you are subscribed to this thread.Message ID: @.***>