Capture TextInput value when button is clicked (search form)

Hi everyone. I was unable to do a proper search in the forum, but I am looking for advice on how to capute a TextInput class value when a Button class is clicked. Behind the click there will be a function that will forward the TextInput Value (basically a search field) and send it to another page (search results page) where the passed value will be submitted into a Fetch. Cracked my head for about 2 hours on this and could not get it to work. Thanks.

Did you go through our getting started tutorial? It covers this as well as a lot of other useful stuff I think you’ll find interesting: https://www.fusetools.com/docs/tutorial/mock-backend

I did actually, but it did not seem to be the solution I was looking for. I ended up with the following (ugly) solution:

function goSearch(arg) {
	var searchTerm = arg.data.searchInput._values[0];
	router.push("searchResults", searchTerm);
}

Since the data was in the arg object I could simply extract it. Then on the searchResults page I used this.Parameter to read the value and assign it to a variable.

Bent Stamnes wrote:

Did you go through our getting started tutorial? It covers this as well as a lot of other useful stuff I think you’ll find interesting: Fuse

I too had the same question recently. It turns our that sometimes you don’t want to assign Observable to a field, you just want a way to get its value without dealing with data binding. As far as I remember, this wasn’t covered in the tutorial.

While it’s nice that you get stuff working by whatever means, I would like to point out that you should do things the way they are supposed to be done. Otherwise you run the risk of your code breaking in future versions.

Since UX and JS run on separate threads, Observables are the proper way to ensure that everything gets across as intended.

Uldis wrote:

Since UX and JS run on separate threads, Observables are the proper way to ensure that everything gets across as intended.

Now everything makes sense. I thought it was more of an “coding style” being enforced by Fuse, but there is actually a technical reason behind it. Will start using Observable() then.