Changing the help text based on a http request during oneditprepare

I have a node that needs to update the help text depending on what it gets back from a http GET request so in the html I have:

oneditprepare: function() {
	$.getJSON("myRequest", function(data) {
		if (data.includes("thing1")) {
			$(".Class1").show();
			$(".Class2").hide();
			$(".Class3").hide();
		} else if (data.includes("thing2")) {
			$(".Class1").hide();
			$(".Class2").show();
			$(".Class3").hide();
		} else if (data.includes("thing3")) {
			$(".Class1").hide();
			$(".Class2").hide();
			$(".Class3").show();
		} else {
			$(".Class1").hide();
			$(".Class2").hide();
			$(".Class3").hide();
			this.warn("couldn't identify which thing");
		}
	});
}

script type="text/x-red" data-help-name="myNode">
<div class="Class1">
	<p>help for thing1</p>
</div>
<div class="Class2">
	<p>help for thing2</p>
</div>
<div class="Class3">
	<p>help for thing3</p>
</div>
</script>

The other side of the request doesn't matter because that is working.

What is happening is that when I open my node it does what it is supposed to do, hides 2 out of 3 help texts. But then in less then a second it shows all three again.
Something seems to be updating the html again to its original form and I can't figure out how to fix it.

Does anyone know what is happening? And hopefully also how I can fix it?

We do not support dynamically modifying the help text. The help content is refreshed whenever the current selection is changed and always reverts to the content provided in the <script> block.

And as the help can be browsed independently of the node, it doesn't necessarily make sense for it to be dynamically changed based on the 'current' node, because the current node could be anything in the workspace.

Ah that's unfortunate, I guess I'll just type docs for the 3 different things with the appropriate headers. And then the user will have to determine which one applies to them themselves.

Thanks for your quick response!

You can show or hide Tip text in the config panel dynamically.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.