Skip to content

onClick event in actions don't seem to work #9

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

Closed
kvriesacker opened this issue Jan 11, 2017 · 5 comments
Closed

onClick event in actions don't seem to work #9

kvriesacker opened this issue Jan 11, 2017 · 5 comments

Comments

@kvriesacker
Copy link

I couldn't find an example in your library where the onClick event for custom buttons seem to work.
Example:
{
"type": "actions",
"items": [
{
"type": "submit",
"style": "btn-info",
"title": "Do It!"
},
{
"type": "button",
"style": "btn-danger",
"title": "Noooooooooooo",
"onClick": "sayNo()"
}
]
}

@dschnelldavis
Copy link
Owner

They didn't work before, but they should now.

I updated the buttons to use custom onClick actions, if available. This fix is now available on both GitHub and NPM starting in version 0.3.0-alpha.26. I haven't added this option to any other control types yet, but tell me if you need it, and I can easily do so.

I tested this as working in the playground, in the set "JSONForm compatibility examples", example "Using event handlers".

It strikes me that there should be a more elegant way to handle this in Angular, without putting executable code directly inside a schema - which is why I didn't initially add this feature. However, I don't know what the best alternative would be instead. Also, one of the design goals of this project is backward-compatibility with JSON Form, which includes this feature, so obviously we should support it.

Anyway, please test the new version and let me know if it works for you.

@dschnelldavis
Copy link
Owner

Since I haven't heard back, I'm going to assume this issue is fixed and close it.

If you have additional problems, post again and we can re-open it if necessary.

Thanks!

@i-am-dror
Copy link

actually, it's not working, you can have a look at the kitchen sink demo, the "Noooooooooooo" button does nothing.
also, style does not apply to it and on the submit button.

@subratastack
Copy link

Any progress on this?

@person2713
Copy link

person2713 commented Mar 7, 2018

try this example:
public layout = [ '*', { type: 'button', title: 'Save', onClick: (event) => { console.log('onClick', event); } } ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants