{"id":16239717,"url":"https://github.com/jalkoby/rjax","last_synced_at":"2025-04-08T09:26:20.789Z","repository":{"id":10941867,"uuid":"13249383","full_name":"jalkoby/rjax","owner":"jalkoby","description":"Elegant responder for ajax requests","archived":false,"fork":false,"pushed_at":"2013-10-08T08:54:45.000Z","size":156,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T06:25:45.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/jalkoby.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-01T16:38:03.000Z","updated_at":"2013-10-08T12:01:36.000Z","dependencies_parsed_at":"2022-09-01T21:02:38.633Z","dependency_job_id":null,"html_url":"https://github.com/jalkoby/rjax","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalkoby%2Frjax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalkoby%2Frjax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalkoby%2Frjax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalkoby%2Frjax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jalkoby","download_url":"https://codeload.github.com/jalkoby/rjax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247811335,"owners_count":21000085,"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-10-10T13:44:48.227Z","updated_at":"2025-04-08T09:26:20.767Z","avatar_url":"https://github.com/jalkoby.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Rjax\n\nElegant responder for ajax requests\n\n{\u003cimg src=\"https://codeclimate.com/github/jalkoby/rjax.png\" /\u003e}[https://codeclimate.com/github/jalkoby/rjax]\n{\u003cimg src=\"https://travis-ci.org/jalkoby/rjax.png?branch=master\" alt=\"Build Status\" /\u003e}[https://travis-ci.org/jalkoby/rjax]\n{\u003cimg src=\"https://badge.fury.io/rb/rjax.png\" alt=\"Gem Version\" /\u003e}[http://badge.fury.io/rb/rjax]\n\n== Installation\n\nAdd this line to your application's Gemfile:\n\n  gem 'rjax'\n\nAnd then execute:\n\n  $ bundle\n\nOr install it yourself as:\n\n  $ gem install rjax\n\n== Usage\n\nRjax will be useful if you have a lot actions which serve http and ajax requests. It might looks like:\n\n  def index\n    @users = User.all\n    render :partials =\u003e 'users', :locals =\u003e { :users =\u003e @users }  if request.xhr?\n    # or\n    render :index_ajax if request.xhr?\n  end\n\nRjax adds `rjax` method in rails controllers.\n\n  class UsersController \u003c ApplicationController\n    def index\n      @users = User.all\n      rjax\n    end\n    # calling rjax method without arguments will render template;\n    # the name of template will contain action_name and wrapper;\n    # in this case expected `index_rjax` template;\n\n    def index\n      @users = User.all\n      rjax @users\n    end\n    # calling rjax method with collection is similar to view helper `render %collection%`;\n    # the only different is also looks for partial with wrapped name;\n    # in this case it will look for partial `_user_rjax` or `_user` and pass variable `user`;\n\n    def index\n      @users = User.all\n      rjax :users =\u003e @users, :other =\u003e :variable\n    end\n    # calling rjax method with Hash will render partial with locals specified in hash;\n    # the name of partial might be specified in :partial key;\n    # if :partial key is missed expected that view folder contains partial with plural form of controller with or without wrapper;\n    # in this case it will be `_users_rjax` or `_users` partial\n\n    def show\n      @user = User.find(params[:id])\n      rjax @user\n    end\n    # in other cases rjax will render partial and pass this variable into partial;\n    # the name of partial will be singular form of controller with or without wrapper;\n    # in this case it will be `_user_rjax` or `_user` partial and pass variable `user`;\n\n    # it also support respond_with\n    def index\n      respond_with do |format|\n        format.html { rjax }\n        format.json\n        format.xml\n      end\n    end\n  end\n\nIf you don't like rjax default wrapper you can configure it:\n\n  # config/initializers/rjax.rb\n  Rjax.config do |config|\n    config.suffix = \"suffix\"\n    config.prefix = \"prefix\"\n  end\n\n  prefix_%template%_suffix\n\n  _prefix_%partial%_suffix\n\n== Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalkoby%2Frjax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjalkoby%2Frjax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalkoby%2Frjax/lists"}