{"action":"created","issue":{"url":"https://api.github.com/repos/cantino/huginn/issues/1434","repository_url":"https://api.github.com/repos/cantino/huginn","labels_url":"https://api.github.com/repos/cantino/huginn/issues/1434/labels{/name}","comments_url":"https://api.github.com/repos/cantino/huginn/issues/1434/comments","events_url":"https://api.github.com/repos/cantino/huginn/issues/1434/events","html_url":"https://github.com/cantino/huginn/pull/1434","id":149000617,"number":1434,"title":"validate agent option json on form submit","user":{"login":"Enfop","id":5695552,"avatar_url":"https://avatars.githubusercontent.com/u/5695552?v=3","gravatar_id":"","url":"https://api.github.com/users/Enfop","html_url":"https://github.com/Enfop","followers_url":"https://api.github.com/users/Enfop/followers","following_url":"https://api.github.com/users/Enfop/following{/other_user}","gists_url":"https://api.github.com/users/Enfop/gists{/gist_id}","starred_url":"https://api.github.com/users/Enfop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Enfop/subscriptions","organizations_url":"https://api.github.com/users/Enfop/orgs","repos_url":"https://api.github.com/users/Enfop/repos","events_url":"https://api.github.com/users/Enfop/events{/privacy}","received_events_url":"https://api.github.com/users/Enfop/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-17T21:57:57Z","updated_at":"2016-04-19T03:35:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cantino/huginn/pulls/1434","html_url":"https://github.com/cantino/huginn/pull/1434","diff_url":"https://github.com/cantino/huginn/pull/1434.diff","patch_url":"https://github.com/cantino/huginn/pull/1434.patch"},"body":"Hi \r\nwhen i tried to save invalid json for the agent_options my changes got lost. I realized that i could validate my json by using the editor toggle. \r\nThe PR adds the same behaviour for the form submit if the agent_options texarea is present. "},"comment":{"url":"https://api.github.com/repos/cantino/huginn/issues/comments/211713182","html_url":"https://github.com/cantino/huginn/pull/1434#issuecomment-211713182","issue_url":"https://api.github.com/repos/cantino/huginn/issues/1434","id":211713182,"user":{"login":"cantino","id":83835,"avatar_url":"https://avatars.githubusercontent.com/u/83835?v=3","gravatar_id":"","url":"https://api.github.com/users/cantino","html_url":"https://github.com/cantino","followers_url":"https://api.github.com/users/cantino/followers","following_url":"https://api.github.com/users/cantino/following{/other_user}","gists_url":"https://api.github.com/users/cantino/gists{/gist_id}","starred_url":"https://api.github.com/users/cantino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cantino/subscriptions","organizations_url":"https://api.github.com/users/cantino/orgs","repos_url":"https://api.github.com/users/cantino/repos","events_url":"https://api.github.com/users/cantino/events{/privacy}","received_events_url":"https://api.github.com/users/cantino/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T03:35:08Z","updated_at":"2016-04-19T03:35:08Z","body":"Great idea @Enfop!\r\n\r\nThere appears to be a bug on Agents that use our form builder, though.  Try it with the Basecamp agent.  I think it binds the events too early.\r\n\r\nMaybe this would work better?\r\n\r\n```coffee\r\n  $('form.agent-form').submit (e) ->\r\n    if $('textarea#agent_options').length\r\n      try\r\n        JSON.parse $('#agent_options').val()\r\n      catch err\r\n        e.preventDefault()\r\n        alert 'Sorry, there appears to be an error in your JSON input. Please fix it before continuing.'\r\n```"}}