That’s likely because the code is running before the components have loaded on the page. You’d need to add code with a timeout to check for that those components are painted on the page first. Or better yet… as soon as we’re live on all the servers with the latest you’ll be able to achieve this with very few lines of code.
In the code below, I’m making an assumption that you have 3 components on the page (component_8, 9, and 10)
We wait for the component_8 to render, check what the field value of field_x is and hide other components based on that value.
TB.render('component_8', function(data) {
fieldValue = data.record.field_40;
if(fieldValue === "Seed"){
TB.hideComponent('component_9');
TB.hideComponent('component_10');
}
})
To add some more context, the response from the function(data) returns several things depending on the component. We can see all of it by simply doing:
console.log(data)
The main things you’ll see are:
This will console log the entire response
everything = data;
console.log(everything);
This is just the Element details
element = data.ele;
console.log(element);
This is the Tadabase Object ID:
objectId = data.objId;
console.log(objectId);
This will output the entire record:
record = data.record;
console.log(record );
This will get the value of a specific field inside the record:
fieldValue = data.record.field_40;
console.log(fieldValue);
This will get the component type (like dataTable, details, calendar etc…)
componentType = data.type;
console.log(componentType);
I know a lot of this is repetitive and you could have deduced all of these by just logging the ‘data’, but I wanted to be a bit descriptive especially since we don’t yet have docs on this new feature.