Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. $('button').click(function(e) { $('input.sel').val(this.name); }
  2.  
  3. def body_page_name
  4. [controller_name.classify.pluralize, action_name.classify].join
  5. end
  6.  
  7. %body{data: {page: body_page_name}}
  8.  
  9. $(function() {
  10. var page = $("body").data("page");
  11. if("object" === typeof window[page])
  12. window[page].init();
  13. });
  14.  
  15. var TicketsShow = new function() {
  16. var self = this;
  17.  
  18. self.init = function() {
  19. // code which may call other functions in self
  20. };
  21. };
  22.  
  23. <body data-controller="<%= controller.controller_name %>"
  24. data-action="<%= controller.action_name %>" >
  25.  
  26. $(document).ready(function() {
  27. if($('body').data('controller')=='stories') {
  28. $('.story').click(function(e) {
  29. var u=$(this).data('url');
  30. u && (document.location=u);
  31. });
  32. }
  33. });
  34.  
  35. <body class='page1'>
  36.  
  37. $('.page1 button').click(function(e) { $('input.sel').val(this.name); }
  38.  
  39. module ApplicationHelper
  40. def body_attributes
  41. controller = params[:controller].gsub('/', ' ')
  42. action = params[:action]
  43. version = @version ? "version_#{@version}" : nil
  44. {
  45. class: ([controller, action, version] - [nil]).join(' ')
  46. }
  47. end
  48. end
  49.  
  50. !!! 5
  51. %html
  52. %head
  53. ...
  54. %body{body_attributes}
  55.  
  56. $(function () {
  57. if ($('body.pledge.new, body.pledge.create').length > 0) {
  58. // do work here...
  59. }
  60. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement