Skip to content

How would I add a link, in a "template" UI element, that opens an entry in a slideout? #15203

Closed Answered by brandonkelly
thupsi asked this question in Q&A
Discussion options

You must be logged in to vote

You can do that like so:

{% set buttonId = "button#{random()}" %}
<button id="{{ buttonId }}" class="btn">Edit entry</button>

{% js %}
(() => {
  const id = '{{ buttonId|namespaceInputId }}';
  $(`#${id}`).on('activate', () => {
    Craft.createElementEditor('craft\\elements\\Entry', {
      elementId: 100,
    });
  });
})();
{% endjs %}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants