Skip to content

Conversation

@rday
Copy link

@rday rday commented Mar 28, 2014

...function for that field when adding a new record.

My specific use case was to allow users to upload a file. By using this 'custom' field type, I can upload the file, modify the meta inside my record, and save everything appropriately.

    fields: {
            upload: {
                list: false,
                edit: false,
                type: 'custom',
                title: 'Upload File',
                display: function(data) {
                    var $fieldView = $('<div/>');
                    var $upload = $('<input />', {
                        'type': 'file',
                        'id': 'file_upload',
                        'name': 'files'
                    });
                    // This will be wrapped with the appropriate jtable divs
                    $fieldView.append($upload);

                    // When we receive the file info, this runs
                    $upload.bind('change', function() {
                        var s3upload = new S3Upload({
                            onFinishS3Put: function(url, signedResult) {
                                // Now that everything has finished, we can modify the Edit-url
                                // element, and when jtable saves the record, the correct url will be saved
                                $('#Edit-url').val(url);
                            }
                        });
                    });

                    return $fieldView;
                }
             }
        }

…ay function for that field when adding a new record
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant