diff --git a/app/assets/javascript/vue_r/application.rb b/app/assets/javascript/vue_r/application.rb index 5170883..b89d570 100644 --- a/app/assets/javascript/vue_r/application.rb +++ b/app/assets/javascript/vue_r/application.rb @@ -38,13 +38,13 @@ module VueR def trigger(key) puts "Trigger:#{key}" effects = get_subscribers_for(key) - effects.each {|effect| effect() } + effects.each {|effect| effect.call() } end def get_subscribers_for(key) key = key.to_sym unless @subscribers.has_key?(key) - @subscribers[key] = [] + @subscribers[key] = Set.new end @subscribers[key] end diff --git a/app/assets/javascript/vue_r/mounter.rb b/app/assets/javascript/vue_r/mounter.rb index 3b14ef0..61da525 100644 --- a/app/assets/javascript/vue_r/mounter.rb +++ b/app/assets/javascript/vue_r/mounter.rb @@ -49,8 +49,16 @@ module VueR end @application.watch_effect(proc) end + + def mount_event(element , name) - puts "Event: #{name}" + native_name = name.gsub("e_" , "") + ruby = element[name] + puts "Event: #{native_name}:#{ruby}" + element.on!(native_name) do + got = @application.eval(ruby) + puts "Clicked #{got}" + end end end end diff --git a/app/views/kanta/show.html.haml b/app/views/kanta/show.html.haml index ef52791..f0c38ca 100644 --- a/app/views/kanta/show.html.haml +++ b/app/views/kanta/show.html.haml @@ -3,11 +3,13 @@ = #@image.attributes .flex.justify-center - %a.underline{ e_click: "hi" , r_class: 'bg'} + %a.underline{ e_click: "bg_change" , r_class: 'bg'} {{ bg }} :opal class Clicker < VueR::Application - + def bg_change + self.bg = "bg-cyan-50" + end end kanta = Clicker.new(bg: 'bg-cyan-200')