{"action":"opened","issue":{"url":"https://api.github.com/repos/mixpanel/mixpanel-js/issues/29","labels_url":"https://api.github.com/repos/mixpanel/mixpanel-js/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/mixpanel/mixpanel-js/issues/29/comments","events_url":"https://api.github.com/repos/mixpanel/mixpanel-js/issues/29/events","html_url":"https://github.com/mixpanel/mixpanel-js/issues/29","id":70014933,"number":29,"title":"Mixpanel-JS track_form strips the button data from POST","user":{"login":"dstosik","id":816901,"avatar_url":"https://avatars.githubusercontent.com/u/816901?v=3","gravatar_id":"","url":"https://api.github.com/users/dstosik","html_url":"https://github.com/dstosik","followers_url":"https://api.github.com/users/dstosik/followers","following_url":"https://api.github.com/users/dstosik/following{/other_user}","gists_url":"https://api.github.com/users/dstosik/gists{/gist_id}","starred_url":"https://api.github.com/users/dstosik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dstosik/subscriptions","organizations_url":"https://api.github.com/users/dstosik/orgs","repos_url":"https://api.github.com/users/dstosik/repos","events_url":"https://api.github.com/users/dstosik/events{/privacy}","received_events_url":"https://api.github.com/users/dstosik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-22T03:55:30Z","updated_at":"2015-04-22T03:55:30Z","closed_at":null,"body":"Hello,\r\n\r\nI have a form with multiple buttons, and each one should send to a different Rails action.\r\n\r\n```html\r\n<input name=\"free_subscribe\" type=\"submit\" value=\"Subscribe for free\">\r\n```\r\n\r\n```rails\r\n#routes.rb\r\n# Routes the request to 2 different actions depending on which button was clicked.\r\npatch :confirm, constraints: lambda {|req| req.params.has_key?(:free_subscribe)}, action: :free_subscribe\r\npatch :confirm\r\n```\r\n\r\nBefore using `mixpanel.track_form`, when I click a button of the form, the POST data includes its value: `free_subscribe:Subscribe for free`, and the right controller action is fired.\r\n\r\nWhen we try to track the form using `mixpanel.track_form`, the button's value is not sent with the POST data anymore, and it makes it impossible, server side, to know which button was clicked.\r\n\r\nHere is a simple Javascript snippet that you can use to reproduce Mixpanel's problem in simpler conditions:\r\n\r\n```js\r\n$('form').submit(function(evt) {\r\n  evt.preventDefault();\r\n  form = this;\r\n  console.log('In submit callback');\r\n  console.log(form);\r\n  setTimeout(function() {\r\n    console.log('In setTimeout callback');\r\n    console.log(form);\r\n    form.submit();\r\n  }, 0);\r\n})\r\n```\r\n\r\nSimilar code can be found in Mixpanel JS library, in [mixpanel.js#L1544-L1553](https://github.com/mixpanel/mixpanel-js/blob/master/mixpanel.js#L1544-L1553).\r\n\r\nAny suggestion on how to fix, or work around this?\r\n\r\nThanks,\r\n\r\nDavid"}}