I have added Search Button with search textbox to end of Go JJS Diagram. I am able to Search Nodes first time. But unable to Search next matching node by again clicking on Search button multiple times with same search text.
Code :
function searchDiagram() { // called by button
var input = document.getElementById("mySearch");
if (!input) return;
myDiagram.focus();
myDiagram.startTransaction("highlight search");
if (input.value) {
// search four different data properties for the string, any of which may match for success
// create a case insensitive RegExp from what the user typed
var safe = input.value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
var regex = new RegExp(safe, "i");
var results = myDiagram.findNodesByExample({ text: regex },
{ nation: regex },
{ title: regex },
{ headOf: regex });
myDiagram.highlightCollection(results);
// try to center the diagram at the first node that was found
if (results.count > 0) myDiagram.centerRect(results.first().actualBounds);
} else { // empty string only clears highlighteds collection
myDiagram.clearHighlighteds();
}
myDiagram.commitTransaction("highlight search");
}