I faced exactly the same problem today and came up with this “hack”. It works for button elements and I haven’t tested it with anything else so your mileage may vary. Basically you need to call a javascript action within the nanoflow and execute something like this:
function disable_after_click() {
// BEGIN USER CODE
let dijit = window.dijit.registry.toArray().filter(d => d.focused).pop();
let el = document.getElementById(dijit.id);
el.disabled = true;
el.classList.add('disabled');
return Promise.resolve(true);
// END USER CODE
}
The idea came to me once I saw the ‘focused’ attribute on the element in the widget registry.
Like I said, it’s probably considered a hack and maybe not ideal for a production environment!
What do you mean with “the element calling the nanoflow”? Do you mean the Button that was clicked? Or the input widget that triggered the event?
I haven’t played around much with the javascript actions.
But I reckon you can use the .bind(this) ES5 method to your promise function or you can try using the ES6 arrow notation for your resolve and reject functions => which automatically makes this available I believe. Haven’t tested it nor can I tell you what would be the “this” element in this scenario.
So if you test this I would be curious to your results.