Saltar navegación

[Resuelto] A View with multiple Forms using AJAX only works for the first item in the View

This support ticket is created hace 3 meses, 1 semana. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por Gavin hace 3 meses, 1 semana.

Asistido por: Minesh.

Autor
Mensajes
#2779992

I have a View that displays the child CPT Replies of a Post.

Post
> Reply 1
> Reply 2
> Reply 3

For each Reply, I have inserted the same Reply form, that creates a Reply to the original Post.

Post
> Reply 1
>> Reply Form
> Reply 2
>> Reply Form
> Reply 3
>> Reply Form

If I use AJAX to submit the Reply Form, it only submits for Reply 1 and not Reply 2 or Reply 3.

If I do not use AJAX it works fine.

I have checked the CRED form IDs in the output and they are all unique.

#2780005

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

There is no such feature available but you maybe workaround this by adding some custom code.

Here is the related ticket that might help you and you will get the idea and you may need to adjust the code as required:
=> https://toolset.com/forums/topic/submit-multiple-forms-at-once/#post-2111533

For example:

 jQuery( document ).ready( function($){
 
        $("#mybutton").click( function( event ){
             
          $("table .wpt-form-submit").each(function(i){
            var $this = this;
            setTimeout(function(){ $($this).click() }, i * 1000)
          });
           
        });
     
    });
#2780018

Hi Minesh

Thanks. I am not trying to submit more than one form at the same time, just any of the single Reply Forms.

I can submit the Reply Form for Item 1 on its own and it works correctly, the page reloads and the Reply is visible, but when I click submit on the Reply Form for Item 2, Item 3, or Item n, it 'looks' as if it is working, the page reloads, but the Reply CPT is not created.

It is strange that it works for the first form and not the others.

Gavin

#2780019

Here is a link to a screen recording:

enlace oculto

#2780026

I should point out there are no JavaScript errors in the console that could be preventing the AJAX form submission from working.

#2780045

Getting closer...

When I removed the content field code (as follows) from the reply in the form, it worked!

<!-- Content -->
[cred_generic_field type='textarea' field='post_content' placeholder="Post a reply..."]
{
"required":0,
"default":"[wpv-post-body template='None']",
"persist":1
}
[/cred_generic_field]

#2780047

I replaced this content code with:

[cred_generic_field field='post_content' type='textarea' class='' urlparam='' placeholder="Post a reply..."]
{
"required":1,
"validate_format":0,
"default":""
}
[/cred_generic_field]

#2780049

Not sure how I had got the persist:1 in the original code... weird... but I guess that was what was killing the forms from working.