How do I know when a user switches between tabs?

I would like to know when a user switches between tabs. What is the best way to do this?   It seems that there is no 'on select' microflow or similar in the Mendix default tab container that can do this. I already tried to add a HTMLSnippet to catch the event using the following example: However in Mendix that gives me 'Error while evaluating javascript input: TypeError: $(...).tabs is not a function'. Any suggestions? Thanks,
3 answers

Thanks for your valuable inputs, eventually I went for the following using the jquery enabled HTML snippet widget:

$( function() {
    var tabhrefs = $("[class^=mx-name-tabPage]");
    for (var i = 0; i < tabhrefs.length; i++) {
        tabhrefs[i].addEventListener("click", tabClicked);

function tabClicked(event) {
    var target = || event.srcElement; 
    console.log('Click on ' + target.innerHTML);
    // do something

A more Mendix integrated Dojo widget would indeed be nice too in case there are more users that need to act on tab changes.


Can you post the full script? The way to go is to add an eventlistener to the tabpane change event of a dojo tabcontainer, see:


Hi Alexander,

In my personal experience Mendix i.e. dojo with its AMD and jQuery don"t go together very well.  That is why I would suggest to try and write any javascript code in pure i.e. vanilla javascript.
Here is how do the jQuery operations in javascript: Selecting objects


registering event handler

object.addEventListener("select", myScript);

scheduling an onload "ready" event handler

window.onload = function() {

I hope this helps,