Class: IRuby::Input::File
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
46
47
48
49
50
51
52
53
54
|
# File 'lib/iruby/input/file.rb', line 46
def widget_html
widget_label do
input(
type: 'file',
:'data-iruby-key' => @key,
class: 'form-control iruby-file'
)
end
end
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/iruby/input/file.rb', line 25
def widget_js
" $('.iruby-file').change(function() {\n var input = $(this);\n\n $.grep($(this).prop('files'), function(file) {\n var reader = new FileReader();\n\n reader.addEventListener(\"load\", function(event) {\n input.data('iruby-value', {\n name: input.val(),\n data: event.target.result\n });\n });\n\n reader.readAsDataURL(file);\n });\n });\n JS\nend\n"
|