JS ActionButton not working

Everything related to the development of modules in jamovi
Post Reply
jcthrawn
Posts: 7
Joined: Fri Jul 26, 2024 1:49 pm

JS ActionButton not working

Post by jcthrawn »

Hi,

I’m on Jamovi 2.6.44.0, I’m trying to add custom JS in a module I use in a university statistical course, but whatever I do the ActionButton I use seem to never work.


I’ve made a minimal example (minimal R/jamovi package in .zip file attached). In the F10 console log, it never triggers any event (see the screenshot attached).
  • The ActionButton defined in my .a.yaml and .u.yaml files (option name: myAction).
    My JS file (test.js) is in the same directory as my analysis files and is referenced in my 0000.yaml manifest (e.g., js: test.js).
    The JS file contains a handler myAction_clicked(ui, event) with a simple console.log() statement for testing.
    After rebuilding and reinstalling the module (using jmvtools::install() from the package root), the Action button appears in the UI, bu clicking the button does not trigger the JS handler (no log appears in the F10 developer console).
What do I miss  ?

Thanks  !

Brice Nocenti


----

PS : I also join the last answer that Perplexity AI gave me, after numerous tests and a long discussion, because it seems quite thorough : https://www.perplexity.ai/search/using- ... LadsyySG5A

« Based on your screenshot and all the troubleshooting steps you’ve described, you have followed Jamovi’s official module conventions exactly (manifest, file locations, naming, rebuild/install, and no duplicate YAML option names). Your test module ("testButton"/"TestAction") is also correct.

The fact that your Action button appears enabled and clickable, but console.log is never triggered, and you see no log on button click, is highly revealing.
Here’s the analysis based on Jamovi’s documentation and actual modules:
Comparison with Jamovi Official Modules

Official modules (like jmv, scatr, etc.) place their JS event handler in the root of their jamovi directory and explicitly specify it in the manifest, just like you did.

Their event handler (e.g., someAction_clicked) always produces console.log when the button is pressed, immediately visible in the F10 console—if the module loads properly.

What’s most likely wrong (by process of elimination):

Jamovi Desktop (Windows version) sometimes ignores or fails to load JS handlers for local modules.

This is a rare bug, but has been reported on Jamovi forums for local custom modules since v2.0, especially with JS files.

The fact that even your minimal test module produces no log at all strongly suggests a systemic bug/limitation in your Jamovi install or its local module sandbox, not your own code.

Your code, file placement, manifest, and module rebuild steps are all correct and consistent with Jamovi documentation and working Jamovi modules.

You correctly renamed and referenced the button, tested with fresh names and structure—yet Jamovi fails to load/call any JS event handler.

What do the symptoms tell us?

Enabled button that does not log: Indicates JS handler is either never loaded or the event bus is disconnected.

No JS errors: If there were syntax errors, Jamovi would typically log a red "syntax error" line at startup, which you do not see.

Official modules work, but not your local custom module: Points to a bug or limitation with custom module JS loading, NOT your scripts.

It persists with new module names, minimalist code, and fresh install: Confirms it's not a naming/caching/conflict issue.

What can you try next?
A. Test with Jamovi portable install (standalone .exe from jamovi.org)

Download the portable version (not the standard installer) of Jamovi, unpack it in a fresh folder, and install your module by dropping it in the appropriate modules/ directory or using jmvtools. See if the JS console logs your console.log on button click there.

B. Try on a different computer

If possible, install Jamovi and your module on a different Windows PC—in case this is specific to your system/environment.

C. Post on Jamovi developer forums

Several custom module devs have encountered similar JS handler issues. Posting your exact scenario (steps replicated above) could get you a fix or confirmation from the development team.

D. Use Jamovi’s official modules as test baseline

Load an official module that uses JS handlers (like “Regression” in jmv), and see if their button clicks are logged in the console.

This will confirm that your Jamovi install correctly supports JS event plumbing, and the issue is truly module-specific.

Summary Table: What’s been ruled out
Potential issue Ruled out?
File names & placement YES
Manifest syntax YES
Option names/YAML setup YES
JS handler code structure YES
Module cache/uninstall YES
Module version YES
Console location YES
Syntax errors in JS YES
Windows file permissions YES (likely)

Conclusion
Your code and approach match the official Jamovi workflow and examples. The persistent lack of JS logs from custom Action buttons suggests a Jamovi desktop bug, module loader limitation, or environment-level JS sandboxing issue—not anything in your scripts or YAML.

Try the portable install or another PC as a critical next step. If that fails, the likely cause is a bug or missing feature in Jamovi’s local module loader.

Let me know what happens with a Jamovi portable install or on another machine.
If you’d like help formulating a forum post for Jamovi developers, just ask!  »
Attachments
Capture d'écran 2025-09-19 183251.png
Capture d'écran 2025-09-19 183251.png (460.92 KiB) Viewed 5315 times
JamoviJSTest.zip
(303.56 KiB) Downloaded 2812 times
User avatar
yurismol
Posts: 50
Joined: Sat May 27, 2023 6:40 am
Location: Chita
Contact:

Re: JS ActionButton not working

Post by yurismol »

1. You must place test.js to jamovi/js folder
2. In the test.u.yaml

Code: Select all

      - type: ActionButton
        name: myAction
        events:
            change: './test::myAction_clicked'
3. Alternatively, you can react to a button press in the test.b.R run function code:

Code: Select all

  .run = function() {
      if (self$options$myAction) {
        ### code here 
      }
  }
jcthrawn
Posts: 7
Joined: Fri Jul 26, 2024 1:49 pm

Re: JS ActionButton not working

Post by jcthrawn »

I just implemented it and it’s working well, thank you very much !
Post Reply