Sha256: 55714cc73e34ef893c49f0aa28e9f47e1df222efdb32b9862a4a5b026778963e

Contents?: true

Size: 679 Bytes

Versions: 9

Compression:

Stored size: 679 Bytes

Contents

module IRuby
  module Input
    class Field < Label
      needs default: nil, type: 'text', js_class: 'iruby-field'

      builder :input do |key='input', **params|
        params[:key] = unique_key key
        add_field Field.new(**params)
      end

      def widget_js
        <<-JS
          $('.iruby-field').keyup(function() {
            $(this).data('iruby-value', $(this).val());
          });
        JS
      end

      def widget_html
        widget_label do
          input(
            type: @type,
            :'data-iruby-key' => @key,
            class: "form-control #{@js_class}",
            value: @default
          )
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iruby-0.8.0 lib/iruby/input/field.rb
iruby-0.7.4 lib/iruby/input/field.rb
iruby-0.7.3 lib/iruby/input/field.rb
iruby-0.7.2 lib/iruby/input/field.rb
iruby-0.7.1 lib/iruby/input/field.rb
iruby-0.7.0 lib/iruby/input/field.rb
iruby-0.6.1 lib/iruby/input/field.rb
iruby-0.6.0 lib/iruby/input/field.rb
iruby-0.5.0 lib/iruby/input/field.rb