{"action":"opened","issue":{"url":"https://api.github.com/repos/gorails-screencasts/shrine-direct-upload-to-s3/issues/1","repository_url":"https://api.github.com/repos/gorails-screencasts/shrine-direct-upload-to-s3","labels_url":"https://api.github.com/repos/gorails-screencasts/shrine-direct-upload-to-s3/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/gorails-screencasts/shrine-direct-upload-to-s3/issues/1/comments","events_url":"https://api.github.com/repos/gorails-screencasts/shrine-direct-upload-to-s3/issues/1/events","html_url":"https://github.com/gorails-screencasts/shrine-direct-upload-to-s3/issues/1","id":186912479,"number":1,"title":"Uploads.js has JS errors - perhaps fixed with the following","user":{"login":"MincePie","id":10092303,"avatar_url":"https://avatars.githubusercontent.com/u/10092303?v=3","gravatar_id":"","url":"https://api.github.com/users/MincePie","html_url":"https://github.com/MincePie","followers_url":"https://api.github.com/users/MincePie/followers","following_url":"https://api.github.com/users/MincePie/following{/other_user}","gists_url":"https://api.github.com/users/MincePie/gists{/gist_id}","starred_url":"https://api.github.com/users/MincePie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MincePie/subscriptions","organizations_url":"https://api.github.com/users/MincePie/orgs","repos_url":"https://api.github.com/users/MincePie/repos","events_url":"https://api.github.com/users/MincePie/events{/privacy}","received_events_url":"https://api.github.com/users/MincePie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-02T20:34:02Z","updated_at":"2016-11-02T20:34:02Z","closed_at":null,"body":"Hi Chris, \r\n\r\nI'm still trying to figure out how to fix the JS errors in the source code without breaking line 2. This is as far as I've made it after the last week's attempts. Posting here in case others trying to learn from your example can help solve the problem.\r\n\r\nCurrently, if the JS errors are fixed (to satisfy JS Hint and google chrome inspector console), then there is an error in line 2 which says:\r\n\r\n_Uncaught TypeError: \"[type=file]\".fileupload is not a function_\r\n\r\nThe following is taken from the video tutorial but is amended to add missing ; and ).\r\n\r\n```\r\n$(document).on(\"turbolinks:load\", function() {\r\n  $(\"[type=file]\".fileupload({\r\n    add: function(e, data) {\r\n      console.log(\"add\", data);\r\n      data.progressBar = $('<div class=\"progress\" style = \"width: 300px\"><div class=\"progress-bar\"></div></div>').insertAfter(\"placeforprogressbar\");\r\n\r\n      var options = {\r\n      \textension: data.files[0].name.match(/(\\.\\w+)?$/)[0],\r\n      \t  _: Date.now()\r\n      \t};\r\n\r\n      \t$.getJSON(\"/images/upload/cache/presign\", options, function(result) {\r\n\t\t\t\t  console.log(\"presign\", result);\r\n\t\t\t\t  data.formData = result['fields'];\r\n\t\t\t\t  data.url = result['url'];\r\n\t\t\t\t  data.paramName = \"file\";\r\n\t\t\t\t  data.submit();\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t\tprogress: function(e, data) {\r\n\t\t\t  console.log(\"progress\", data);\r\n\t\t\t  var progress = parseInt(data.loaded / data.total * 100, 10);\r\n\t\t\t  var percentage = progress.toString() + '%';\r\n\t\t\t  data.progressBar.find(\".progress-bar\").css(\"width\", percentage).html(percentage);\r\n\t\t\t},\r\n\r\n\t\t\tdone: function(e, data) {\r\n\t\t    console.log(\"done\", data);\r\n\t\t    data.progressBar.remove();\r\n\r\n\t\t    var image = {\r\n\t\t\t\t  id: data.formData.key.match(/cache\\/(.+)/)[1],\r\n\t\t\t\t  storage: 'cache',\r\n\t\t\t\t  metadata: {\r\n\t\t\t\t\t  size: data.files[0].size,\r\n\t\t\t\t\t  filename: data.files[0].name.match(/[^/\\\\]+$/)[0],\r\n\t\t\t\t\t  mime_type: data.files[0].type\r\n\t\t\t\t  }\r\n\t\t\t\t};\r\n\r\n\t\t\t\tform = $(this).closest(\"form\");\r\n\t\t\t\tform_data = new FormData(form[0]);\r\n\t\t\t\tform_data.append($(this).attr(\"name\"), JSON.stringify(image));\r\n\r\n\t\t\t\t$.ajax(form.attr(\"action\"), {\r\n\t\t\t\t  contentType: false,\r\n\t\t\t\t  processData: false,\r\n\t\t\t\t  data: form_data,\r\n\t\t\t\t  method: form.attr(\"method\"),\r\n\t\t\t\t  dataType: \"son\"\r\n\t\t\t\t}).done(function(data) {\r\n\t\t\t\t  console.log(\"completed file upload\", data);\r\n\t\t\t\t});\t\r\n\t\t\t}\r\n\t  }));\r\n\t});\r\n```"}}
{"actor":{"display_login":"MincePie"}}