Class: IRuby::Input::Radio
Instance Method Summary
collapse
Methods inherited from Label
#widget_label
Methods inherited from Widget
builder, #content, #widget_css, #widget_display, #widget_join
Instance Method Details
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/iruby/input/radio.rb', line 26
def widget_html
params = {
:'data-iruby-key' => @key,
:'data-iruby-value' => @options.first,
class: 'iruby-radio form-control'
}
widget_label do
div **params do
@options.each do |option|
label class: 'radio-inline' do
input(
name: @key, value: option, type: 'radio'
)
text option
end
end
end
end
end
|
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/iruby/input/radio.rb', line 15
def widget_js
<<-JS
$('.iruby-radio input').change(function(){
var parent = $(this).closest('.iruby-radio');
$(parent).data('iruby-value',
$(parent).find(':checked').val()
);
});
JS
end
|