Button text binding

Hi Guys,

I’m using the standard nodeTemplate and am adding a button to the node with a JS script to redirect somewhere else as follows:

$("Button",<br /> {click: function(){window.location.href="Rd-01.html?asset=" +<br /> $(go.TextBlock, new go.Binding("text", "key"));}},<br /> { alignment: go.Spot.Top, alignmentFocus: go.Spot.Right },<br /> $(go.TextBlock, new go.Binding("text", "key"))));<br />
the button has the right text but the href link doesn’t… what I get is

Rd-01.html?asset=TextBlock("")

How do I get the href to have the right text (as on the Button)?

Many thanks in advance as 1) relatively new to JS and 2) very new to GoJS

Best regards

The problem is that you are mixing JavaScript code (the href assignment statement) with the declaration of the visual structure of a “Button” Panel. You need to find the TextBlock that is actually in the Button and get its TextBlock.text property. Here is one possibility that assigns a name to the TextBlock so that you can call Panel.findObject on it:
$(“Button”,
{ click: function(e, obj) {
var tb = obj.findObject(“TB”);
window.location.href=“Rd-01.html?asset=” + tb.text;
}
},
$(go.TextBlock,
{ name: “TB” },
new go.Binding(“text”, “key”)))

[Please pardon any typos.]