Class: IRuby::Input::Select
Instance Method Summary
collapse
Methods inherited from Label
#widget_label
Methods inherited from Widget
builder, #content, #widget_display, #widget_join
Instance Method Details
21
22
23
24
25
26
27
28
|
# File 'lib/iruby/input/select.rb', line 21
def widget_css
<<-CSS
.iruby-select {
min-width: 25%;
margin-left: 0 !important;
}
CSS
end
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/iruby/input/select.rb', line 40
def widget_html
widget_label do
div class: 'form-control' do
params = {
class: 'iruby-select',
:'data-iruby-key' => @key,
:'data-iruby-value' => @default
}
select **params do
@options.each do |o|
option o, selected: @default == o
end
end
end
end
end
|
30
31
32
33
34
35
36
37
38
|
# File 'lib/iruby/input/select.rb', line 30
def widget_js
<<-JS
$('.iruby-select').change(function(){
$(this).data('iruby-value',
$(this).find('option:selected').text()
);
});
JS
end
|