Data intensive science for everyone. https://galaxyproject.org | https://usegalaxy.org | https://help.galaxyproject.org
make_popupmenu script. I am trying to create a dropdown menu on the success of an ajax call. The ajax call is performed on a button click. The dropdown menu is created but only on the second or sometimes third click on this button. I checked that the program control goes inside make_popupmenu but it is created only after successive clicks.
buttons.append(
$("<a/>")
.addClass("panel-header-button")
.attr('id', 'show-recommendation-' + random_suffix)
.attr('href', '#')
.attr('title', 'Show recommended tools')
.html('<span class="fa-icon-button fa fa-arrow-right"></span>')
.click(e => {
var tool_sequence = self.get_workflow_path(self.workflow.to_simple(), node.id, node.content_id);
console.log(tool_sequence)
Utils.request({
type: "POST",
url: `${getAppRoot()}api/workflows/get_tool_predictions`,
data: {"tool_sequence": tool_sequence},
success: function(data) {
var predicted_names = data.predicted_names,
predicted_ids = data.predicted_ids,
pred_tools = {};
for(var i=0; i < predicted_names.length; i++) {
var name = predicted_names[i];
pred_tools[predicted_ids[i]] = (name => () => {
workflow_globals.app.add_node_for_tool(name, name);
})(name);
}
make_popupmenu($("#show-recommendation-" + random_suffix), pred_tools);
}
});
})
click event through the code on the first click making the second click unnecessary ...