Velo Code - Search Fields against a collection - Publishing Issue

Let’s see if this makes sense.

  1. I have code for a search which works.

  2. Upon publishing the site (with no edits to the site) the relationships for my text / dropdown / search & reset buttons go haywire (like they are trying to relate to the collection listed on the page).

  3. If I return and update each search field (and dissociate the collection…leaving it on ‘choose’ as an option) & publish…it will work till next time I publish the website.

So, my issue is not the search itself (maybe). It is the automatic attempt at ‘relationship’ from the search fields that I created to the collection listed on the page upon publishing.

Page: pci-foundation(.) org/studio-info/

Code Used:
import wixData from ‘wix-data’ ;
$w ( ‘#resetButton’ ). hide ();

$w . onReady ( function () {
//TODO: write your page related code here…

});

function search ( ) {

**let**  title  =  $w ( '#input1' ). value ; 
**let**  programs  =  $w ( '#dropdown1' ). value ; 
**let**  status  =  $w ( '#dropdown2' ). value ; 

$w ( "#dynamicDataset" ). setFilter (  wixData . filter () 
  . contains ( "title" , title ) 
  . contains ( "programs" , programs ) 
  . contains ( "status" , status ) 
) 
  $w ( '#resetButton' ). show (); 
  $w ( '#resetButton' ). enable (); 
  $w ( '#button7' ). hide ();    

}

export function searchButton_click ( event ) {
search ();
}

export function resetButton_click ( event ) {

$w ( "#dynamicDataset" ). setFilter (  wixData . filter ()); 
$w ( '#dropdown1' ). value  =  **undefined** ; 
$w ( '#dropdown2' ). value  =  **undefined** ; 
$w ( '#input1' ). value  =  **undefined** ; 
$w ( '#button7' ). show (); 
$w ( '#button7' ). enable (); 
$w ( '#resetButton' ). hide (); 
$w ( '#dropdown1' ). resetValidityIndication (); 
$w ( '#dropdown2' ). resetValidityIndication (); 
$w ( '#input1' ). resetValidityIndication (); 

}

export function button7_click ( event ) {
search ();
}

Hello, I just checked your site and the search does not seem to work at all and there are console errors.

I"m a little confused by the original question and what you are expecting to see on page load (page load looks fine as far as I can tell) please update the issue or let us know if you have found a resolution. thanks!

You are right. The search does not work.

Let’s parse this out into sections of ‘does this make sense?’ to slice it up.

  1. There are the search fields, which are separate from the collection
  • Does this make sense?
  1. The code makes the relationship between the search fields & the collection
  • Does this make sense?
  1. The search fields AUTOMATICALLY connect themselves with the collection on that page each time the website is published (from ANY page)
  • Does this make sense?
  1. The errors you see are the AUTOMATIC ASSOCIATION of the search fields to the collection causing an error on the page
  • Does this make sense?

Note:
I updated the search fields & published the site. It currently works.

Page Link:
https://www.pci-foundation.org/studio-info/

Questions:

  1. Are you seeing errors now?
  2. Is there a way to prevent AUTOMATIC association of a search field to a collection…so the code can act without duplicity of the field being related?

Side question:

Not to be ungrateful on this addition of collections (I think it’s great).
BUT…
Does WIX have a ‘search app’ that they are in the midst of making (specifically to be applied against a collection on a page)?

It seems like a giant gaping hole to not have search & filter functionality as a byproduct of a collection system as a whole. I think that that should come from your company vs. some outside 3rd party app.

I understand that simple one shot filters can be made, but I also think that about 20 years of base search formats for searches have been identified to create a basic template library. Also, the library is something that makes you better as a company in terms of EASY GUI user tools vs. coders.

If you read your console error, you will see that it is because .hide is not a function. This is becuase you are calling it outside of the page onReady.

$w(‘#resetButton’).hide(); this is sitting below your import statement which is your first problem.

Fix this error first before you continue and that will potentially help you discover the issue.

The search can’t function because you have an immediate error so there is no way to debug that yet. You must follow your errors first.

Here’s the thing Amanda.

You are talking to someone with no code experience.

  1. I hired someone to do this.
  2. They ran into a dead end & wanted me to contact you.
  3. Talking to me as if I understand this will not help either of us.

I did provide the code that I used in the initial request.

Questions:

  1. I know that this isn’t the most sugar-coated request for help, but could you please edit / paste the code back to me working?

  2. Could you recommend me to someone who could do the work correctly?

  3. Here in the forum: Do you help people with code, or just tell them generally what to do?

I’m already 200+ in on costs & 5 days behind schedule. I need help.

This is a community based forum and not a customer support forum. If you are looking to hire someone to write code for you, you will want to reach out to a developer on the wix marketplace .

If you are interested in learning how to debug your code, you may start here .

If you are interested in learning how to code in velo and how the code loads on the page, you may start here

I am sorry you are frustrated, but this is a community space and not a support forum. You may reach out to customer care if you require direct support.