-
-
Notifications
You must be signed in to change notification settings - Fork 32k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IconButton onClick event Handler to Documentation #1340
Comments
onClick should work |
@eguneys shouldn't you rather be using Either way, would you like to submit a PR adding the event to the doc? Should only take a couple minutes :) |
Consider reopening; I believe this got lost somehow. The doc at http://www.material-ui.com/#/components/icon-button still does not contain any info on click handling (including onTouchTap). And it took me over an hour, too. |
Hi, I can't handle the click event on IconButton. What's wrong in my code ??? Icon Button is in a toolbar element. handleToggle() {
|
@LeoPovoa "this" is not bound. Try it with function that's not a class member; if it works, that's your problem. You need to bind your handler to "this". http://stackoverflow.com/questions/29732015/value-of-this-in-react-event-handler |
I have bound the callback function to this in constructor and it still does not work. |
@Paelsis Everything changed in this area 4 days ago, when v.19 came out. For pre-v.19: Be sure to use doc that corresponds to the version you're using; there's a version dropdown at the top of the left navbar on the docs. I don't have time to chase this, but looking at my code I'm seeing that I use |
Thanks a lot, I'll try to update version 🙂
Med vänlig hälsning
Per Gustav Eskilson
Mobil: (+46)733-780749
18 aug. 2017 kl. 22:48 skrev Ed Staub <notifications@github.com<mailto:notifications@github.com>>:
@Paelsis<https://github.com/paelsis> Everything changed in this area 4 days ago, when v.19 came out.
See #7605<#7605> .
I haven't used v.19 yet, but there's a good chance it will fix your problem.
For pre-v.19:
Be sure to use doc that corresponds to the version you're using; there's a version dropdown at the top of the left navbar on the docs.
I don't have time to chase this, but looking at my code I'm seeing that I use onTouchTap on all IconButtons, and I know that works; note that it is documented and onClick is not. Consider trying it. If you haven't used it before, be sure to have the react-tap-event-plugin installed and initialized; see http://www.material-ui.com/v0.18.7/#/get-started/installation
Note well: onTouchTap was removed in v.19.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#1340 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AZkoP7aMXR7UnXTf8j2QTMaArpPMTScpks5sZfimgaJpZM4Fl4FO>.
|
Did you solved this?. Please tell me how... I'm having the same exact situation |
I did it like this and it worked pretty well: |
|
And for the benefit of all the other people who have just spent an hour trying to find out this information it's: event: React.MouseEvent<HTMLButtonElement, MouseEvent> |
Wrap any MUI component over your IconButton. In my case I'm using Box component.
|
IconButton onClick event handler took me a couple of hours to find out.
The text was updated successfully, but these errors were encountered: