All Questions
56 questions
2
votes
0
answers
62
views
sveltekit client - array available sporadically in reactive function
An app showing a list of building systems components with the ability to add a component. Database is Mongodb.
+page.js fetches the list, a definition of the table + populates "lookup" lists ...
0
votes
1
answer
47
views
How to use an array from a JS file to a Svelte file
I have a function in a +page.js file that return { props { data } }. Data is an array. However when I try to use it in svelte with
export let data
It says that it's not an array
What should I do ?
0
votes
1
answer
68
views
Is it possible to limit results from Svelte {#each} loop by a certain amount?
I'm using an {#each} loop to showcase data, but I'm curious if Svelte has a way to limit the results by an integer.
For example, if I had the following array and loop:
const object = [1, 2, 3, 4, 5];
...
0
votes
1
answer
34
views
weird issue when updating a value of an array in a object
Assume the following state object:
const state = writable({});
$state = {value: ['a','b','c'], label: 'test'};
And replace one specific item of the array like this:
$state.value[1] = 'e';
Ok, no big ...
1
vote
1
answer
104
views
Svelte: Binding of value inside an array does not work
I created a REPL to illustrate my issue.
So I have an array with elements and those elements bind there properties to input fileds.
But changing those values does nothing. On log or add all changes ...
0
votes
1
answer
802
views
How do I get an element in a Svelte array using a value derived from a select element?
I have a list of users which I iterate over to populate a selection pull down but I need to use the selected user to pull their age from the array. I've bound value to the variable select but I can't ...
0
votes
1
answer
54
views
Svelte value assignment does not update
Why doesn't this value assignment work?
<script>
let numbers = [1, 2, 3, 4];
function addNumber() {
numbers = numbers.push(numbers.length + 1);
}
$: sum = numbers....
0
votes
1
answer
511
views
Duplicate elements in #each Svelte
I have a component on related posts on the Svelte website. It works, but the problem is that it duplicates the articles in the block. That is, for example, if I have three identical tags contained in ...
1
vote
2
answers
298
views
How can I limit object from an array in svelte
I'm searching in svelte documentation about this, but I can't get it.
What I want is to show only 4 objects from an array
For example:
let data = [
{id:1, name: 'John'},
{id:2, name: 'Peter'},
...
0
votes
2
answers
24
views
Array2 gets set to a array1 unexpectedly in Svelte
For some reason, images2 gets set to the same thing as images1 instead of galleryData.splice(0, 3), this is not what I want to happen.
The second console.log(images2) prints what galleryData.splice(0, ...
0
votes
2
answers
569
views
What's the proper way to render a single element of an array in Svelte?
I have an array of nodes, which in my case are objects that have some data, including an id. I only want to display the active node, which is found by comparing the node ID with the active node ID. I ...
-1
votes
2
answers
62
views
How to play ad at each array time?
I am trying to play/show a video Advertisement(just a h1 tag) at each index value in the array. For example; the first item in the array is 5. So at 5 seconds, I want the video to pause and play an ad....
2
votes
1
answer
1k
views
Toggle add/remove items to a writable array store in Svelte
I have a Svelte store that's a writable array.
To begin, I have a separate array of names, and am using that to populate a selection panel the user can click on.
The idea is that if they click on the ...
1
vote
3
answers
2k
views
Why is Svelte not re-triggering a function and/or rerendering when some variable changes? [duplicate]
I'm relatively new to Svelte and I understand some basic concepts. I know that it's reactive on assignment. But I can't seem to figure out why exactly this doesn't work. Here's a little demo snippet ...
1
vote
1
answer
244
views
Automatically updating svelte JSON with XHR
I am completely new to Svelte (or other JavaScript reactive framework).
I worked for years only with jQuery.
Let us assume, ich have the following arrays and a formatter function ...
let quotes = [{
...