Trigger a microflow when the tab is on the button? Ok, you’ll have a use case for that, so let’s go:
$(document).ready(function() { //Wait for all dom-elements to be rendered
try{
let TriggerHappy=$('.triggerhappybutton')[0]; // find input-element of triggerhappybutton
TriggerHappy.addEventListener("focus", function(){
<Call your microflow from javascript>
});
} catch (error) {}
});
And then there is the bit how to call a microflow from javascript. Use mx.data.action for that passing along your module.microflow:
mx.data.action({
params: {
actionname: "MyFirstModule.CalledMicroflowFromJS"
},
callback: function(obj) {
// no MxObject expected
alert("Just petted the cat a little");
},
error: function(error) {
alert(error.message);
}
});
For examples see https://apidocs.rnd.mendix.com/8/client/mx.data.html