Replies: 3 comments
-
|
The short answer is that traditional Instead, the standard pattern in Trilium render notes is to bind event handlers from JavaScript using render.html: <a href="#" class="my-alert-link">Click Here</a>myscripts.js: const $link = api.$container.find('.my-alert-link');
$link.on('click', (e) => {
e.preventDefault();
alert('Hello World!');
});The key points:
If you really want the inline onclick approach, you'd need to explicitly attach the function to To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
Beta Was this translation helpful? Give feedback.
-
|
I did it like this:
|
Beta Was this translation helpful? Give feedback.
-
|
@diyoyo , you should also look into Preact JSX, you can define handlers much more easily and make use of bundles. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm a bit confused with the way scripts are loaded in renderNotes.
(First of all, I know some solutions could just be a complete widget development, but that'll be for later).
Let's say I have a simple function calling "alert(msg)" in the JS lying below the HTML of the rendernote:
How can I call it from a button or a link as simply as :
?
Thanks.
Of course, I assume here the structure of the files is correct:
Beta Was this translation helpful? Give feedback.
All reactions