{"action":"closed","issue":{"url":"https://api.github.com/repos/jejacks0n/mercury/issues/484","labels_url":"https://api.github.com/repos/jejacks0n/mercury/issues/484/labels{/name}","comments_url":"https://api.github.com/repos/jejacks0n/mercury/issues/484/comments","events_url":"https://api.github.com/repos/jejacks0n/mercury/issues/484/events","html_url":"https://github.com/jejacks0n/mercury/issues/484","id":105812752,"number":484,"title":"Snippets with javascripts included","user":{"login":"mediatainment","id":1597621,"avatar_url":"https://avatars.githubusercontent.com/u/1597621?v=3","gravatar_id":"","url":"https://api.github.com/users/mediatainment","html_url":"https://github.com/mediatainment","followers_url":"https://api.github.com/users/mediatainment/followers","following_url":"https://api.github.com/users/mediatainment/following{/other_user}","gists_url":"https://api.github.com/users/mediatainment/gists{/gist_id}","starred_url":"https://api.github.com/users/mediatainment/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediatainment/subscriptions","organizations_url":"https://api.github.com/users/mediatainment/orgs","repos_url":"https://api.github.com/users/mediatainment/repos","events_url":"https://api.github.com/users/mediatainment/events{/privacy}","received_events_url":"https://api.github.com/users/mediatainment/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-10T14:03:11Z","updated_at":"2015-09-10T15:54:54Z","closed_at":"2015-09-10T15:54:54Z","body":"Hi there, I am quite ready with my snippet implementation with an image dropzone. I am using dropzone.js. \r\n\r\nI have found out, that when I put javascript into the snippet it gets not rendered. \r\nThe following code is placed in the ``options.html.erb`` but is not rendered in the dom. I dont know why.\r\n\r\n**How can I fire an jQuery selector when the snippet is rendered?** \r\n\r\n\r\n```erb\r\n<%= form_for 'options', {url: '/mercury/images', html: {multipart: true, class: 'dropzone form-horizontal', style: 'width:615px'}} do |f| %>\r\n    <div class=\"fallback\">\r\n      <%= f.file_field :file, class: \"span6 string optional\" %>\r\n    </div>\r\n<% end %>\r\n\r\n<script type=\"text/javascript\" charset=\"utf-8\">\r\n$(this).ready(function () {\r\n        $.getScript\"/assets/dropzone.js\", function () {\r\n            console.log($(\".dropzone\"));\r\n\r\n            $(\".dropzone\").dropzone({\r\n                url: \"/mercury/images\",\r\n                init: function () {\r\n                    this.on(\"addedfile\", function (file) {\r\n                        alert(\"Added file.\");\r\n                    });\r\n                    this.on(\"success\", function (file, response) {\r\n                        $('#options_image_id').val(response['image']['id']);\r\n                    });\r\n                }\r\n            });\r\n        });\r\n    })\r\n\r\n</script>\r\n```\r\n\r\nconsole log output:\r\n\r\n    [prevObject: jQuery.fn.init[1], context: document, selector: \".dropzone\"]\r\n\r\n\r\nWhen I paste the same javascript code in the console, all works as expected and the console output is:\r\n\r\n    [form.dropzone.form-horizontal, prevObject: jQuery.fn.jQuery.init[1], context: document, selector: \".dropzone\"]\r\n\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26586461-snippets-with-javascripts-included?utm_campaign=plugin&utm_content=tracker%2F134071&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F134071&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"}}