Sha256: 58fc8ae79954b37c116687f79bbe807aaab698ed9de1aab3d12f27a8afc09816
Contents?: true
Size: 1.19 KB
Versions: 10
Compression:
Stored size: 1.19 KB
Contents
# Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use Opal in this file: http://opalrb.com/ # # # Here's an example view class for your controller: # <% if namespaced? -%> require <%= namespaced_file_path.to_s.inspect %> <% end -%> <% module_namespacing do -%> class <%= class_name %>View # We should have <body class="controller-<%%= controller_name %>"> in layouts def initialize(selector = 'body.controller-<%= class_name.underscore %>') @selector = selector end def setup on(:click, 'a', &method(:link_clicked)) end def link_clicked(event) event.prevent puts "Hello! (You just clicked on a link: #{event.current_target.text})" end private attr_reader :selector, :element # Uncomment the following method to look for elements in the scope of the # base selector: # # def find(selector) # Element.find("#{@selector} #{selector}") # end # Register events on document to save memory and be friends to Turbolinks def on(event, selector = nil, &block) Element[`document`].on(event, selector, &block) end end <%= class_name %>View.new.setup <% end -%>
Version data entries
10 entries across 10 versions & 1 rubygems