{"action":"created","issue":{"url":"https://api.github.com/repos/winston/rails_utils/issues/15","labels_url":"https://api.github.com/repos/winston/rails_utils/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/winston/rails_utils/issues/15/comments","events_url":"https://api.github.com/repos/winston/rails_utils/issues/15/events","html_url":"https://github.com/winston/rails_utils/pull/15","id":57773663,"number":15,"title":"Updated javascript_initialization to take in options to define custom action name","user":{"login":"yzdong","id":7276292,"avatar_url":"https://avatars.githubusercontent.com/u/7276292?v=3","gravatar_id":"","url":"https://api.github.com/users/yzdong","html_url":"https://github.com/yzdong","followers_url":"https://api.github.com/users/yzdong/followers","following_url":"https://api.github.com/users/yzdong/following{/other_user}","gists_url":"https://api.github.com/users/yzdong/gists{/gist_id}","starred_url":"https://api.github.com/users/yzdong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yzdong/subscriptions","organizations_url":"https://api.github.com/users/yzdong/orgs","repos_url":"https://api.github.com/users/yzdong/repos","events_url":"https://api.github.com/users/yzdong/events{/privacy}","received_events_url":"https://api.github.com/users/yzdong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-16T07:41:32Z","updated_at":"2015-02-23T08:23:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/winston/rails_utils/pulls/15","html_url":"https://github.com/winston/rails_utils/pull/15","diff_url":"https://github.com/winston/rails_utils/pull/15.diff","patch_url":"https://github.com/winston/rails_utils/pull/15.patch"},"body":"Hey Winston! Modified javascript_initialization so that we can pass it an optional value to specify which action name it should use.\r\n\r\nThe use case is that one controller action could be rendering two different views, but since they are called from the same controller action, javascript_intialization will generate the same javascript. \r\n\r\nWith options, you can provide a action_name in a view template and still use javascript_initalization at the application layout level to generate two different sets of javascript. \r\n\r\nPossible modifications would be to allow it to take in a custom controller_class as well. \r\n\r\nLet us know what you think! "},"comment":{"url":"https://api.github.com/repos/winston/rails_utils/issues/comments/75504485","html_url":"https://github.com/winston/rails_utils/pull/15#issuecomment-75504485","issue_url":"https://api.github.com/repos/winston/rails_utils/issues/15","id":75504485,"user":{"login":"winston","id":2112,"avatar_url":"https://avatars.githubusercontent.com/u/2112?v=3","gravatar_id":"","url":"https://api.github.com/users/winston","html_url":"https://github.com/winston","followers_url":"https://api.github.com/users/winston/followers","following_url":"https://api.github.com/users/winston/following{/other_user}","gists_url":"https://api.github.com/users/winston/gists{/gist_id}","starred_url":"https://api.github.com/users/winston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/winston/subscriptions","organizations_url":"https://api.github.com/users/winston/orgs","repos_url":"https://api.github.com/users/winston/repos","events_url":"https://api.github.com/users/winston/events{/privacy}","received_events_url":"https://api.github.com/users/winston/received_events","type":"User","site_admin":false},"created_at":"2015-02-23T08:23:50Z","updated_at":"2015-02-23T08:23:50Z","body":"This is what I think would be better in terms of \"API\":\r\n\r\nIn the helper `javascript_initialization`, I would add:\r\n\r\n```\r\nif content_for?(js_init_method)\r\n  if(#{application_name}.#{page_controller_class}.init_#{js_init_method}) { #{application_name}.#{page_controller_class}.init_#{js_init_method}(); } \r\nend \r\n```\r\n\r\nafter the `page_action_class` call:\r\n\r\n```\r\nif(#{application_name}.#{page_controller_class}.init_#{page_action_class}) { #{application_name}.#{page_controller_class}.init_#{page_action_class}(); } \r\n```\r\n\r\nThen to use it, all you have to do in your view is to add:\r\n\r\n```\r\ncontent_for :js_init_method { 'custom_view' } \r\n```\r\n\r\nDoes this make sense? wdyt?\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}