0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Rails plugin to render partial view by ajax
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 4.0.0
 Project Readme

AjaxRender

Simplify your ajax implementation

Before

If you implement ajax with no plugin, you may write code as follows

# app/controllers/tests_controller.rb
class TestsController < ApplicationController
  def ajax_action
    @value = params[:value]
    respond_to do |format|
      format.js
    end
  end
end
<%# app/views/tests/ajax_action.js.erb %>
$('.some_element').html(<%= render '/tests/partial', locals: { value: @value } %>);

After using AjaxRender

You can avoid creating such js in your views directory by AjaxRender

# Gemfile
gem 'ajax_render'
# app/controllers/tests_controller.rb
class TestsController < ApplicationController
  def ajax_action
    ajax_render '/tests/partial', replace: '.some_element', locals: { value: params[:value] }
  end
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request