AnsweredAssumed Answered

Having a button pass a variable into a function

Question asked by thewabbit on Jul 6, 2015
Latest reply on Jul 7, 2015 by thewabbit

Hi all

 

What I'm trying to do is when a list of points are added to a map, they are also added to a list which is displayed to the user. What I want to be able to do is beside each of these items is have a 'delete' button which will pass the button ID into a function. I have got all the code figured out apart from passing a unique variable into a function to delete the correct point. Below is the code I have so far:

 

This is the code which creates a delete button with a unique ID (basically i want that id passed into the function)

 string = '<p>' + consentLocattr[i][1] + '<button id='+i+' data-dojo-attach-event="onclick:delete('+i+')">Delete</button></p>';

 

And here is the function (at the moment i'm just trying to get it to work)

delete: function(item){

alert(item);



},

 

Cheers, and sorry about the formatting, it doesn't seem to like me currently

 

Hamish

 

Message was edited by: Hamish Kingsbury

Outcomes