Skip to main content

resolver

Description

enables the multi-area mode and defines whether an element needs a menu

Type

function

Example

<script>
// the id inside the resolver is the value of the "data-context-id" attribute
const resolver = id => id;
var activate;
</script>

<!--a menu will appear for all items with the "data-context-id" attribute -->
<ActionMenu {options} {resolver} bind:handler={activate} />
{#each items as item(item.id)}
<div class="item" on:click={activate} data-context-id={item.id}></div>
{/each}

Details

The result of the resolver call will be provided in the resulting click event as ev.detail.item.

Check the examples of valid resolvers below:

const allowAll = (id, ev) => true;
const allowElementsWithCorrectAttribute = (id, ev) => return id;
const allowAndReturnTaskObject = (id, ev) => return tasks[id];

Related article: Using Action Menu for multiple targets

Related sample: