I have:

= form_tag document_template_sessions_path, :id =>
"document_template_session_frm", :remote => true do

In the controller I have:

class DocumentTemplateSessionsController < ApplicationController

def create
session[:document] = Hash.new
session[:document][:prot_n] = params[:document][:prot_n]
session[:document][:prot_data] = params[:document][:prot_data]
session[:document][:subject] = params[:document][:subject]

In the .js.coffee file I have:

$(document).on "click", "#document_template_session_btn", ->
$("#document_template_session_frm").submit()
$("#document_template_session_frm").on 'ajax:success', ->
$("#invite_frm").submit()

The status after $("#document_template_session_frm").submit() is 200 OK.
but it seems that ajax:success is not considered because invite_frm
submit is not called.
I need a render call at the end of create method?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Paul at Apr 15, 2012 at 1:33 pm
    Just a wild guess, but are you returning valid json from the server?
    I've seen that when I have a syntax error in my returned json.
    On Sat, Apr 14, 2012 at 6:48 AM, Mauro wrote:
    I have:

    = form_tag document_template_sessions_path, :id =>
    "document_template_session_frm", :remote => true do

    In the controller I have:

    class DocumentTemplateSessionsController < ApplicationController

    def create
    session[:document] = Hash.new
    session[:document][:prot_n] = params[:document][:prot_n]
    session[:document][:prot_data] = params[:document][:prot_data]
    session[:document][:subject] = params[:document][:subject]

    In the .js.coffee file I have:

    $(document).on "click", "#document_template_session_btn", ->
    $("#document_template_session_frm").submit()
    $("#document_template_session_frm").on 'ajax:success', ->
    $("#invite_frm").submit()

    The status after  $("#document_template_session_frm").submit() is 200 OK.
    but it seems that ajax:success is not considered because invite_frm
    submit is not called.
    I need a render call at the end of create method?

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Mauro at Apr 15, 2012 at 5:00 pm

    On 15 April 2012 15:33, Paul wrote:
    Just a wild guess, but are you returning valid json from the server?
    I've seen that when I have a syntax error in my returned json.
    Sorry for my ignorance.
    I simply run create method from document_template_session_controller.
    Why it works if I don't submit the second form and doesn't run if I
    submit also the second form?

    On Sat, Apr 14, 2012 at 6:48 AM, Mauro wrote:
    I have:

    = form_tag document_template_sessions_path, :id =>
    "document_template_session_frm", :remote => true do

    In the controller I have:

    class DocumentTemplateSessionsController < ApplicationController

    def create
    session[:document] = Hash.new
    session[:document][:prot_n] = params[:document][:prot_n]
    session[:document][:prot_data] = params[:document][:prot_data]
    session[:document][:subject] = params[:document][:subject]

    In the .js.coffee file I have:

    $(document).on "click", "#document_template_session_btn", ->
    $("#document_template_session_frm").submit()
    $("#document_template_session_frm").on 'ajax:success', ->
    $("#invite_frm").submit()

    The status after  $("#document_template_session_frm").submit() is 200 OK.
    but it seems that ajax:success is not considered because invite_frm
    submit is not called.
    I need a render call at the end of create method?

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Mauro at Apr 16, 2012 at 10:31 am

    On 15 April 2012 19:00, Mauro wrote:
    On 15 April 2012 15:33, Paul wrote:
    Just a wild guess, but are you returning valid json from the server?
    I've seen that when I have a syntax error in my returned json.
    Sorry for my ignorance.
    I simply run create method from document_template_session_controller.
    Why it works if I don't submit the second form and doesn't run if I
    submit also the second form?
    it seems that can't do two or more consecutive submits via ajax in the
    manner I've posted.
    Can you suggest a solution?

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Draiken at Apr 17, 2012 at 1:41 pm
    I think you're just not adding the callback before the submit.

    When you submit and you don't have the callback set, the callback will
    obviously never get called.

    Try this:
    $(document).on "click", "#document_template_session_btn", ->
    $("#document_template_session_frm").on 'ajax:success', ->
    $("#invite_frm").submit()
    $("#document_template_session_frm").submit()

    On Apr 16, 7:31 am, Mauro wrote:
    On 15 April 2012 19:00, Mauro wrote:
    On 15 April 2012 15:33, Paul wrote:
    Just a wild guess, but are you returning valid json from the server?
    I've seen that when I have a syntax error in my returned json.
    Sorry for my ignorance.
    I simply run create method from document_template_session_controller.
    Why it works if I don't submit the second form and doesn't run if I
    submit also the second form?
    it seems that can't do two or more consecutive submits via ajax in the
    manner I've posted.
    Can you suggest a solution?
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Mauro at Apr 17, 2012 at 8:56 pm

    On 17 April 2012 13:35, Draiken wrote:
    I think you're just not adding the callback before the submit.

    When you submit and you don't have the callback set, the callback will
    obviously never get called.

    Try this:
    $(document).on "click", "#document_template_session_btn", ->
    $("#document_template_session_frm").on 'ajax:success', ->
    $("#invite_frm").submit()
    $("#document_template_session_frm").submit()
    I've tried this:

    $(document).on "click", "#document_template_session_btn", ->
    $("#document_template_session_frm").submit()
    $("#document_template_session_frm").on 'ajax:success', ->
    $("#invite_frm").submit()

    It seems to work well now.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedApr 14, '12 at 10:48a
activeApr 17, '12 at 8:56p
posts6
users3
websiterubyonrails.org
irc#RubyOnRails

3 users in discussion

Mauro: 4 posts Draiken: 1 post Paul: 1 post

People

Translate

site design / logo © 2021 Grokbase