Im using D3 and JS.
I have a function that creates buttons and one of the parameters is onClick which runs when the buttons is clicked (obviously).
For example:
simpleButton(imageURL, width, height, title, onClick){
.attr("xlink:href", imageUrl) //-original image
.attr( "width", width) //-icon width
.attr( "height", height) //-icon height
.on("click", onClick)
.append("svg:title")
.text(title); //-give the button a title
}
Now one of my buttons I'm going to use to hide some shapes (i.e. set visibility:hidden).
So I have created another function to hide the selection, something like:
hideSelection(selection){
selection.classed("hidden", true);
}
This function takes on one parameter so that I can pass through what I want to hide.
So for example what I thought would work looks like this:
simpleButton("\images\dog", 100, 100, "dog", hideSelection(dog));
Now, this does work, but it works straight away without me clicking. I know it's because I'm calling the hideSelection straight away because of the parenthesis-().
But my question is, how do I stop calling this function straight away when running it ? How do I run a function with parameters via another function that has parameters (if that makes any sense at all)?