Skip Navigation

[Résolu] After refreshing search results with AJAX the View disappears

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: When I trigger an AJAX update of my View, all the results disappear.

Solution: Ensure your Post Relationship Filter is set to "The current post in the Loop"

This support ticket is created Il y a 7 années. 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 7 réponses, a 2 voix.

Dernière mise à jour par toolset-dave Il y a 7 années.

Assisté par: Christian Cox.

Auteur
Publications
#596235

Hi, I have a Custom search which uses AJAX for refreshing search results. If I load the page for first time the View (displays the lowest price from child posts of the parent CPT) will display correctly, but if I click on search button or change anything from filtering, it will not show the View output.

View contains only this code:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
		[types field='cena-varianty' output='raw'][/types]
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		
	[/wpv-no-items-found]
[wpv-layout-end]

This displays the View:

[wpv-view name='nejnizsi-cena-varianty-zazitku']
#596347

Hi, can you share some screenshots showing the View settings in wp-admin, including the Content Selection, Query Filter, Query Options?

Then, in your loop output area try the following code as a test:

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
    <wpv-loop>
        Inside the loop<br />
        [types field='cena-varianty' output='raw'][/types]<br />
    </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
         No items found
    [/wpv-no-items-found]
[wpv-layout-end]

What are the results before and after filtering?

#596351
printscreen-1.png

Hi, the result before filtering: "Inside the loop" and after filtering "No items found".

#596402

There are no Query Filters applied to this View except the post relationship filter. So I'm not sure what you mean by "if I click on search button or change anything from filtering, it will not show the View output." How are you changing anything from filtering? What filter controls do you have in this View? Please take a screenshot showing your Filter Editor area, or copy + paste the code here, or let me take a look at your wp-admin area so I can make some recommendations. If that's okay with you, please provide login credentials in the private reply fields here. Let me know where I can see the search form on your site, and I will take a look at how everything is set up.

#596923

Sorry, I don't see any prices here:
lien caché

The screenshot you posted is not the View shown at /zazitky. This is the View shown at /zazitky:
lien caché

It has quite a few query filters and filter controls, and in the loop template it has several conditionals. I believe the conditionals are hiding the prices. When I load the page for the first time, I do not see any prices in the results, so I'm not sure what the problem is, but this looks suspicious:

[wpv-conditional if="( '[wpv-view name='nejnizsi-cena-varianty-zazitku']' ne '' )"]

I know we worked on another ticket about removing spaces from View output, and I believe you may need to apply the same filters to this View if you want to use it in a conditional.

#596957

Hi,

you can see the prices on the site lien caché (see printscreen lien caché) and this is after hiting the search button or changing anything on search parameters in frontend: lien caché

The conditionals work fine (its used for defining 0 as a free product,...)

#596971
comments.png
first-load.png
ajax-update.png

Please edit the Post Relationship filter here:
wp-admin/admin.php?page=views-editor&view_id=972

You should select "The current post in the Loop" instead of "Post where this View is shown".

#596975

Thank you, Christian, it helped.