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

Already on GitHub? Sign in to your account

ajaxified inquiry form #98

wants to merge 1 commit into


None yet
2 participants

keram commented Dec 18, 2012

hello guys,
improved inquiry form with ajax with properties:

  • in default configuration it behaves like before only is submitted through ajax
  • when javascript is not available it fallback to current old implementation
  • you can load form through ajax on other pages than contact.
    You just need put this snippet of code where you want:
<%= render :partial => 'refinery/inquiries/inquiries/javascripts' %>
  • customizable and configurable
    you can set form id, form holder,some callbacks etc.
    For example you want initialize inquiry form only after your custom event (maybe click on button)
    then you may put this snippet of code:
<%= render :partial => 'refinery/inquiries/inquiries/javascripts', :locals => {:initialize_onload => false} %>
<a id="frm-a" href="/contact">contact form</a>
<% content_for :javascripts do %>
$(function() {

    $('#frm-a').on('click', function () {
        new refinery.Inquiry({
            holder : { id : 'custom-holder-id', append_to: '#body_content_title' },
            onload : {
                fnc : window.alert,
                args : 'Inquiry Form loaded and binded'
    return false;
<% end %>

and more..

In next step I would like write documentation and implement some polyfill for #77

ajaxified inquiry form
sanitize passed form holder id prevent xss
refactoring & with bugfix on customized form holder
removing forgotted debug setting from inquiry model

@parndt parndt commented on the diff Jan 23, 2013

+ end
+ def render_json_response(type, hash)
+ unless [ :ok, :redirect, :error ].include?(type)
+ raise "Invalid json response type: #{type}"
+ end
+ json = {
+ :status => type,
+ :html => nil,
+ :message => nil,
+ :errors => nil,
+ :to => nil }.merge(hash)
+ render_options = {:json => json}
+ render(render_options)

parndt Jan 23, 2013


could just be

render :json => json

@keram keram closed this Jun 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment