Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3 remote form not triggering callback
    primarykey
    data
    text
    <p>I have a remote form that is populated by jQuery with an AJAX request. Then, I am binding this form to an AJAX callback but the callback is not being triggered.</p> <pre><code>var msgSuccess=function(evt, data, status, xhr){ alert('ok!!!'); console.log(evt); console.log(data); console.log(status); console.log(xhr); } var bindMsg = function() { // BIND IT TO THE CALLBACKS $("#composeMsgPopup") .live('ajax:beforeSend', loadingCallback) .live('ajax:success', msgSuccess) .live('ajax:error', failureCallback) .live('ajax:complete',completeCallback); } $.ajax({ // GETTING THE FORM CODE url: link, type: "get", success: function(response, textStatus, jqXHR) { ans=response; $("#popup_content").html(ans); $("#popup").bPopup(); bindMsg(); }, error: function(jqXHR, textStatus, errorThrown) { failureCallback(errorThrown, textStatus, jqXHR); }, complete: function(jqXHR, textStatus) { completeCallback("", jqXHR, textStatus); }, beforeSend: loadingCallback }); </code></pre> <p>The code for the form:</p> <pre><code>&lt;%= form_for(:conversation, :remote =&gt; true, :url=&gt; {:controller=&gt;:conversations,:action=&gt;:create}, :html=&gt;{:id =&gt; 'composeMsgPopup' }) do |f| %&gt; &lt;div id="founder-name" class="field"&gt;&lt;b&gt;Recipient: &lt;%= @user.name %&gt;&lt;/b&gt;&lt;/div&gt; &lt;div class="field"&gt; &lt;%= f.label :subject,"Subject" %&gt; &lt;%= f.text_field :subject,:class=&gt;"composeMsgField" %&gt; &lt;/div&gt; &lt;div class="field"&gt; &lt;%= f.label :content,"Message Content" %&gt; &lt;%= f.text_area :content,:class=&gt;"composeMsgField" %&gt; &lt;/div&gt; &lt;%= f.hidden_field :to_user, :value =&gt; @user.id %&gt; &lt;%= f.submit "Send", :class=&gt;"submitbt",:id=&gt;'sendMessage' %&gt; &lt;% end % &gt; </code></pre> <p>I have tried to bind with bind() or on() but it does not work. The code is executed but when I submit the form the callback is not executed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload