Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to specify a 'custom' type for a field, and run the display ... #1221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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