I'm all mixed up! :-( :'( HELP PLEASE!

Hi all,

I don’t know what to do anymore! :cry:

I’ve been trying to fix this by myself but I just don’t seem to get over this weird red dot waltz! :frowning:

Here’s the site : merlinregis.wixsite.com/accueil

I don’t understand why the system is giving me such a hard time with the code!

The visitor can enter key words in the input box or search with the drop menus

Right now, the errors I get in the developper console are :

public/pages/i93j3.js: Unexpected token (5:1) 3 | $w(“#Inventaire_Dataset”).setFilter( wixData.filter()) 4 | export function searchInput_keyPress(event, $w) { > 5 | .contains(“veh_year”, $w(“#input1”)) | ^ 6 | .contains(“brand”, $w(“#input1”)) 7 | .contains(“model”, $w(“#input1”)) 8 | .contains(“partName”, $w(“#input1”))

Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.

Loading the code for the Accueil page. To debug this code, open i93j3.js in Developer Tools.

There was an error in your scriptTypeError: n is not a function

Sometimes there are less errors, but basically that DA**** red dot just wanders around no matter what moving around I do.

Here’s the code :

// Input search
import wixData from ‘wix-data’;
$w(“#Inventaire_Dataset”).setFilter( wixData.filter())
export function searchInput_keyPress(event, $w) {
.contains(“veh_year”, $w(“#input1”))
.contains(“brand”, $w(“#input1”))
.contains(“model”, $w(“#input1”))
.contains(“partName”, $w(“#input1”))
.find()
.then(res => {
console.log(“Dataset is now filtered”);
} )
.catch( (err) => {
console.log(err)
} } );
$w(‘#table1’).rows = res.items;}

// ===========

//Dropbox search
import wixData from ‘wix-data’;
export function searchDropdown1_change(event, $w) {
$w(“#Inventaire_Dataset”).setFilter( wixData.filter()
.contains(“veh_year”, $w(“#dropdown1”))
.contains(“brand”, $w(“#dropdown2”))
.contains(“model”, $w(“#dropdown3”))
.contains(“partName”, $w(“#dropdown4”))
.find()
.then(res => {
$w(‘#table1’).rows = res.items;}

};
}

Thanks in advance for ALL ANSWERS :slight_smile:

public/pages/i93j3.js: Unexpected token, expected ; (38:8)
  36 | 		.find() // Run the query
  37 | 		.then(res => {
> 38 | 			 Set the table data to be the results of the query
     | 			     ^
  39 | 			$w('#table1').rows = res.items;
  40 | }
  41 | }

It looks like you tried to write a comment here but forgot the // that goes before it. That will fix one problem of yours, at any rate. You might also want to check to make sure that the Inventaire collection has the correct permissions set. That’s what this error seems to be pointing out:

 Failed to load initial data Error: The current user does not have permissions to read on the Inventaire collection. 

OK, I think I have something here…

First, I’d like to mention that it TOTALLY isn’t clear, for a newbie like me, when people talk about the browser developper tools that it’s supposed to be understood that we should go into the console section to see the errors that it mentions. There’s probably much more to it, but for now, my point aims the console.

Now, using the developper tools’ CONSOLE, I got a LITTLE bit more help than what the editor’s little dots say. But now, the errors have mostly transferred from the editor to the developper console :frowning:

One thing I just realized though :

Since I have 4 dropmenus, shouldn’t I have 4 export function lines? 1 for each drop menu? It’s NOT like in the input box that the visitor can enter key words from “any of the fields”, It’s one drop menu per field. Anyway, “IF AT LAST” I can get what’s already coded to work, from there, I’ll just duplicate what’s done for the other drop menus.

Here’s my CORRECTED code :

//Input search
import wixData from ‘wix-data’;
$w(“#Inventaire_Dataset”).setFilter( wixData.filter())
export function searchInput_keyPress(event, $w) {
contains(“veh_year”, $w(“#input1”))
.contains(“brand”, $w(“#input1”))
.contains(“model”, $w(“#input1”))
.contains(“partName”, $w(“#input1”))
.find()
.then(res => {
console.log(“Dataset is now filtered”);
} )
.catch( (err) => {
console.log(err)
$w(‘#table1’).rows = res.items;}

// ===========

//Dropbox search

export function searchDropdown1_change(event, $w) {
$w(“#Inventaire_Dataset”).setFilter( wixData.filter())
contains(“veh_year”, $w(“#dropdown1”))
.contains(“brand”, $w(“#dropdown2”))
.contains(“model”, $w(“#dropdown3”))
.contains(“partName”, $w(“#dropdown4”))
.find()
.then(res => {
$w(‘#table1’).rows = res.items;}
} );

In the editor :

  • I have an error message for line 1 saying that ESLint failed to validate… does it matter? It’s just a comment.
  • Line 22 : Unexpected token. When I refer to the dev. tools’ console, console, I see :

public/pages/i93j3.js: Unexpected token, expected , (22:0)

Can you clarify to me the details? The way I understand it is that either there’s something unexpected in the line, OR that a comma IS expected.

That’s all for the editor’s error messages, but the dev. tools’ console says quite a lot more

For shortening of this message, I’ll just put the errors (in red, 2 of them), without the “attentions” (in yelow, 20 of them) :

public/pages/i93j3.js: Unexpected token, expected , (22:0)

22 | export function searchDropdown1_change(event, $w) {
| ^

There was an error in your script

TypeError: n is not a function
at n ( scriptRunner.js:14 )
at UserCodeStore.js:22
at Array.map ()
at t.value ( UserCodeStore.js:17 )
at u ( loadHandler.js:136 )
at lodash.min.js:67
at o ( worker.js:93 )
at Array.forEach ()
at n ( worker.js:74 )
at self.onmessage ( worker.js:55 )

Thanks to all who wish to contribute to this “unmixing up” :slight_smile:

Hi,
You have some syntax errors. this is the correct syntax

export function searchInput_keyPress(event, $w) {
	$w("#Inventaire_Dataset").setFilter(wixData.filter()
		.contains("veh_year", $w("#input1"))
		.contains("brand", $w("#input1"))
		.contains("model", $w("#input1"))
		.contains("partName", $w("#input1"))
	);

}

And:

export function searchDropdown1_change(event, $w) {
	$w("#Inventaire_Dataset").setFilter(wixData.filter()
		.contains("veh_year", $w("#dropdown1"))
		.contains("brand", $w("#dropdown2"))
		.contains("model", $w("#dropdown3"))
		.contains("partName", $w("#dropdown4"))
		.find()
		.then(res => {
			$w('#table1').rows = res.items;
		})
	);
}

Please update in your progress.
Roi

MANY thanks Roi! :slight_smile:

No more red dots! :slight_smile:

What I’m wondering though, is that the table doesn’t update on keypress nor on drop menu change :frowning:

Any idea what could cause that?

It’s “THE” element that I’ve been trying to fix since the beginning, but obviously, with red dots, there was work to be done. I wouldn’t put stuff on the table before the table has its four solid legs :wink:

But now that all the code is correct, The table doesn’t show the results of what the visitor searches for.

If you type a year in the input box, you should only see the results for that year in the table. OR the same thing if you select a year in the drop menu 1.

As always, thanks to anybody’s 2¢ :slight_smile:

$w(“#dropdown1”) returns the selected drop-down object. You need to grab the value from it in order to use it in your call to contains(), similarly with the input fields. i.e.

$w(“#dropdown1”).value
// &
$w(“#input1”).value

Hello Nicholas,

Ah! GREAT! I knew there was something missing! I suppose you know how it is… You’re SO concentrated on what could be wrong that you DON’T see the obvious! :slight_smile:

Always good to get an outsider’s look :slight_smile:

Oooops… doesn’t seem to want to work.

If you want to try it :
https://merlinregis.wixsite.com/accueil

Since not ALL the brands and models are populated, you can try for something I know is in there :

Year (Année) : 2016
Brand (Marque) : Mini
Model (Modèle) : MiniCooper
Partname : Airbag

Do I need to make an export function for EACH dropmenu? Since I only have one created for now, I expect that the results should show ALL the 2016 makes and models and parts even if we chose brand, model and part.

And is the input box capable of searching word by word or does it look in each field for EVERYTHING that is typed in it ? If so, obviously, the year field would not return any results if it’s ALSO searched for Mini, MiniCooper, and airbag.

No errors in the console, but the results don’t STILL update in the table.

Does it make a difference to have or not “event, $w” ?

//Input search
import wixData from ‘wix-data’;
export function searchInput1_keyPress(event, $w) {
$w(“#Inventaire_Dataset”).setFilter(wixData.filter()
.contains(“veh_year”, $w(“#input1”).value)
.contains(“brand”, $w(“#input1”).value)
.contains(“model”, $w(“#input1”).value)
.contains(“partName”, $w(“#input1”).value)

); 

}

// ===========

//Dropbox search

export function searchDropdown1_change(event, $w) {
$w(“#Inventaire_Dataset”).setFilter(wixData.filter()
.contains(“veh_year”, $w(“#dropdown1”).value)
.contains(“brand”, $w(“#dropdown2”).value)
.contains(“model”, $w(“#dropdown3”).value)
.contains(“partName”, $w(“#dropdown4”).value)
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
})
);
}

Lines 1 and 19 have that little yellow triangle saying “Parameter ‘event’ is never used.”

Thanks in advance :slight_smile:

Am I better to do a query or a filter?

Nayeli seems to have nailed it with query.

I feel your mini rant. I find the combination of easy to user front design with incomplete documentation (that includes a full list of error codes, what they mean and step by step written instructions not only frustrating and times consuming, but also misleading. I think that the user needs to have an exact picture of what they want to design and then plan out whether or not it’s feasible on the Wix platform for an actual honest to goodness beginner. Good luck with your project!

I’m receiving this message.

“Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.”