Sha256: 841b29b6febd518eadc080d9a2fbd656be98120ca61ba1722352ecb0e1fd4f00

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

# For demo purposes. Not used in testing.
class SimpleFormWithFileUpload < Netzke::Base
  js_configure do |c|
    c.extend = "Ext.form.Panel"
    c.body_padding = 10
    c.on_submit = <<-JS
      function(){
        var msg = function(title, msg) {
            Ext.Msg.show({
                title: title,
                msg: msg,
                minWidth: 200,
                modal: true,
                icon: Ext.Msg.INFO,
                buttons: Ext.Msg.OK
            });
        };

        var me = this;

        this.getForm().submit({
          url: this.netzkeEndpointUrl('server_submit'),
          success: function(fp, o){
            msg("Success", 'Your file is uploaded!');
        },
          failure: function(){msg("Failure", 'Server did not inform us about success');}
        });
      }
    JS
  end

  action :submit

  def configure(c)
    super
    c.items = [{ xtype: :filefield, emptyText: 'Select an image', fieldLabel: 'Photo', buttonText: '...' }]

    c.bbar = [:submit]
  end

  endpoint :server_submit do |params, this|
    # because this endpoint wasn't called in the normal way, we cannot do anything like this (it won't have any effect):
    # this.set_title('File uploaded')

    # But this will define whether the client is informed about success or not:
    this.success = true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netzke-core-0.8.4 test/core_test_app/app/components/simple_form_with_file_upload.rb
netzke-core-0.8.3 test/core_test_app/app/components/simple_form_with_file_upload.rb
netzke-core-0.8.2 test/core_test_app/app/components/simple_form_with_file_upload.rb