{"id":18513346,"url":"https://github.com/jbox-web/remotipart","last_synced_at":"2025-04-09T06:33:12.057Z","repository":{"id":146101450,"uuid":"169012542","full_name":"jbox-web/remotipart","owner":"jbox-web","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-06T16:07:14.000Z","size":297,"stargazers_count":2,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-06T19:14:44.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbox-web.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-04T01:05:19.000Z","updated_at":"2024-09-06T16:07:17.000Z","dependencies_parsed_at":"2023-05-04T00:47:34.239Z","dependency_job_id":"ecf63547-8cc1-470f-8856-6be96eaee079","html_url":"https://github.com/jbox-web/remotipart","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fremotipart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fremotipart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fremotipart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fremotipart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbox-web","download_url":"https://codeload.github.com/jbox-web/remotipart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223367294,"owners_count":17134071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T15:37:46.039Z","updated_at":"2024-11-06T15:37:46.869Z","avatar_url":"https://github.com/jbox-web.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Remotipart: Rails jQuery File Uploads\n\n[![GitHub license](https://img.shields.io/github/license/jbox-web/remotipart.svg)](https://github.com/jbox-web/remotipart/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/jbox-web/remotipart.svg)](https://github.com/jbox-web/remotipart/releases/latest)\n[![CI](https://github.com/jbox-web/remotipart/workflows/CI/badge.svg)](https://github.com/jbox-web/remotipart/actions)\n[![Code Climate](https://codeclimate.com/github/jbox-web/remotipart/badges/gpa.svg)](https://codeclimate.com/github/jbox-web/remotipart)\n[![Test Coverage](https://codeclimate.com/github/jbox-web/remotipart/badges/coverage.svg)](https://codeclimate.com/github/jbox-web/remotipart/coverage)\n\nRemotipart is a Ruby on Rails gem enabling AJAX file uploads with jQuery in Rails 5 remote forms.\n\nThis gem augments the native Rails jQuery remote form functionality enabling asynchronous file uploads with little to no modification to your application.\n\n* [How AJAX File Uploads Work](http://www.alfajango.com/blog/ajax-file-uploads-with-the-iframe-method/)\n\n## Installation\n\nPut this in your `Gemfile` :\n\n```ruby\ngit_source(:github){ |repo_name| \"https://github.com/#{repo_name}.git\" }\n\ngem 'remotipart', github: 'jbox-web/remotipart', tag: '1.6.0'\n```\n\nthen run `bundle install`.\n\n\n## Usage\n\n* For multipart / forms with file inputs, set your form_for to remote as you would for a normal ajax form : `remote: true`\n* When Javascript is enabled in the user's browser, the form, including the file, will be submitted asynchronously to your controller with : `format: 'js'`\n\nIf you need to determine if a particular request was made via a remotipart-enabled form :\n\n* from your Rails controller or view :\n\n```ruby\nif remotipart_submitted?\n```\n\n* from your javascript :\n\n```javascript\n  $(form).bind(\"ajax:success\", function(){\n    if ($(this).data('remotipartSubmitted')) {\n      ...\n    }\n  });\n```\n\nIf you want to be notified when the upload is complete (which can be either success or error)\n\n* from your javascript :\n\n```javascript\n  $(form).on(\"ajax:remotipartComplete\", function(e, data){\n    console.log(e, data)\n  });\n```\n\n\n## Example\n\n`sample_layout.html.erb` :\n\n```html\n\u003c%= form_for @sample, html: { multipart: true }, remote: true do |f| %\u003e\n  \u003cdiv class=\"field\"\u003e\n    \u003c%= f.label :file %\u003e\n    \u003c%= f.file_field :file %\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"actions\"\u003e\n    \u003c%= f.submit %\u003e\n  \u003c/div\u003e\n\u003c% end %\u003e\n```\n\n`sample_controller.rb` :\n\n```ruby\ndef create\n  respond_to do |format|\n    if @sample.save\n      format.js\n    end\n  end\nend\n```\n\n`create.js.erb` :\n\n```javascript\n// Display a Javascript alert\nalert('success!');\n\u003c% if remotipart_submitted? %\u003e\n  alert('submitted via remotipart')\n\u003c% else %\u003e\n  alert('submitted via native jquery-ujs')\n\u003c% end %\u003e\n```\n\nThe content type requested from the application can be overridden via the \u003ctt\u003edata-type\u003c/tt\u003e HTML5 attribute:\n\n`sample_layout2.html.erb` :\n\n```html\n\u003c%= form_for @sample, html: { multipart: true }, remote: true, data: { type: :html } do |f| %\u003e\n  \u003cdiv class=\"field\"\u003e\n    \u003c%= f.label :file %\u003e\n    \u003c%= f.file_field :file %\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"actions\"\u003e\n    \u003c%= f.submit %\u003e\n  \u003c/div\u003e\n\u003c% end %\u003e\n```\n\nIn this case, the application should serve HTML using a \u003ctt\u003ecreate.html.erb\u003c/tt\u003e template instead of JavaScript.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbox-web%2Fremotipart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbox-web%2Fremotipart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbox-web%2Fremotipart/lists"}