Last active
August 29, 2015 14:11
-
-
Save vdel26/9842ab601716f720a9e1 to your computer and use it in GitHub Desktop.
Update button workaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <section> | |
| <!-- BUTTON --> | |
| <!-- add this where you would put the tag {{ 'Regenerate' | update_button: application.update_user_key_url }} --> | |
| <form action="{{ application.update_user_key_url }}" class="button_to js-regenerateButton" method="post"> | |
| <div> | |
| <input name="_method" type="hidden" value="put"> | |
| <input class="btn btn-danger btn-xs" type="submit" value="Regenerate"> | |
| </div> | |
| </form> | |
| <!-- ENDBUTTON --> | |
| </section> | |
| <!-- add this script tag to the bottom of the page --> | |
| <script> | |
| $(function () { | |
| var csrfToken = document.querySelector('meta[name=csrf-token]').content, | |
| formContent = document.querySelector('.js-regenerateButton > div'), | |
| inputCsrf = document.createElement('input'); | |
| inputCsrf.type = 'hidden'; | |
| inputCsrf.name = 'authenticity_token'; | |
| inputCsrf.value = csrfToken; | |
| formContent.appendChild(inputCsrf); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment