Class: IRuby::Input::Select

Inherits:
Label
  • Object
show all
Defined in:
lib/iruby/input/select.rb

Instance Method Summary collapse

Methods inherited from Label

#widget_label

Methods inherited from Widget

builder, #content, #widget_display, #widget_join

Instance Method Details

#widget_cssObject



14
15
16
# File 'lib/iruby/input/select.rb', line 14

def widget_css
  '.iruby-select { margin-left: 0 !important }'
end

#widget_htmlObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/iruby/input/select.rb', line 28

def widget_html
  widget_label do 
    div class: 'form-control' do 
      params = {
        class: 'iruby-select', 
        :'data-iruby-key' => @key,
        :'data-iruby-value' => @options.first
      }
      
      select **params do 
        @options.each {|o| option o }
      end
    end
  end
end

#widget_jsObject



18
19
20
21
22
23
24
25
26
# File 'lib/iruby/input/select.rb', line 18

def widget_js
  <<-JS
    $('.iruby-select').change(function(){
      $(this).data('iruby-value', 
        $(this).find('option:selected').text()
      );
    });
  JS
end