Adam Procter Posted September 4, 2020 Share Posted September 4, 2020 This will draw me buttons for each of my nodes but when ever I click on the buttons and console.log (this.name) I only ever get the last node_id ? Which seems odd for (i = 0; i < Object.keys(this.myNodes).length; i++) { for (j = 0; j < Object.keys(this.configPositions).length; j++) { if (this.configPositions[j].node_id == this.myNodes[i].node_id) { buttons.name = this.myNodes[i].node_id buttons.lineStyle(0) buttons.beginFill(0xcab6ff, 1) // x, y, radius buttons.drawCircle( this.configPositions[j].x_pos + this.configPositions[j].width, this.configPositions[j].y_pos + this.configPositions[j].height / 2, 15 ) buttons.endFill() // names it the last one only? } } Quote Link to comment Share on other sites More sharing options...
jonforum Posted October 4, 2020 Share Posted October 4, 2020 node_id are not a valide attribute in html element. you will need use `.getAttribute('node_id`)` https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.