Vue: Choosing an option during the execution of setInterval

I'm facing an issue where I can't select an option while a setInterval function is running on the page. The main problem is that an option cannot be selected at the same time as the setInterval timer fires.

let updateDelay = 100;

var vueObj = new Vue({
  el: '#app',
  data: {
    items: ['item 1', 'item 2', 'item 3'],
    timer: 60,
    choice: ''
  }
})

setInterval(function() {
  vueObj.timer = vueObj.timer - updateDelay/1000;
}, updateDelay);
<script src="https://unpkg.com/vue"></script>

<div id="app">
  <div id='timer'>Timer: {{ timer.toFixed(1) }}</div>
  <br>
  <select v-model='choice' size=3>
    <option v-for='item in items' :value='item'>{{item}}</option>
  </select>
</div>

  1. Pressing keys for selection works without any issues.
  2. The problem disappears when v-model is removed from the select.
  3. Choosing becomes smoother when the timer interval is longer.

Check out this link for more information.

Answer №1

It appears that there may be an issue with Vue, as you mentioned. It would be a good idea to report this problem on the VueJS repository by following this link:

If you encounter difficulties, you can still make your code work by manually implementing the v-model:

<select size="3" @input="choice = $event.target.value">
    <option v-for="item in items" :value="item">{{item}}</option>
</select>

You can view a functional example here: http://jsfiddle.net/8io5dtns/21/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to store object data within an Angular component

This is a sample component class: export class AppComponent { categories = { country: [], author: [] } constructor(){} getOptions(options) { options.forEach(option => { const key = option.name; this.categories[k ...

Make Bootstrap Panel Full Width with Highcharts Data

I am currently working on displaying graphs using the Highcharts library on three televisions. All televisions have a FULL HD resolution of 1920 x 1080. I have one Bootstrap panel containing a graph in the panel-body. <div class="panel panel-blue"> ...

Items added to a form using jQuery will not be submitted when the form is posted

Issues with posting data from dynamically appended options in a form select using jQuery have been noticed. When an appended option is selected and the form is submitted, the value does not get posted (in this case, in an email template). Adding another no ...

Browser local storage protection

Utilizing local storage to preserve specific data for my website has been beneficial. Each necessary object is stored so that users can access them on their browser (in chrome: Resource -> Local Storage). My objective now is to make these objects unrea ...

Using JSON to insert an array into an object with identical key name

var arr = ['1', '2', '3'] var part = {} var partContents = [] arr.map(function(i){ partContents.push({ obj: i }) part['text'] = partContents }) console.log(part); Is there a way to create separate arrays with ...

The axios library fails to send formdata to the server

Recently, I've been working on an axios code to handle form data submission. Here's the snippet of the code: updatesetting: function(){ let formData = new FormData(); formData.append('email', this.email); formData.append(&a ...

What does [] represent in the context of the [].forEach.call() method?

I'm a bit confused about the meaning of [] in the code snippet below. Is it just indicating the most recently declared array? Can someone provide clarification? In this particular example, we have two arrays named racersList and volunteersList stored ...

What is the best way to incorporate an image zoom-in effect into a flexible-sized block?

Having a fluid grid with 3 blocks in one row, each set to width:33.3%. The images within these blocks are set to width: 100% and height: auto. I am looking to implement a zoom-in effect on hover for these images without changing the height of the blocks. I ...

New functionality introduced in JavaScript ES6: Sets

I am currently using a Set data structure to store unique primitive values, but I am facing an issue when trying to add unique objects based on their property values. Below is an example of my code: "use strict" var set = new Set(); var student1 = { ...

The connection of props in VueJS

Looking to establish linking dependencies between props in a VueJS component? Specifically, I want to set up a scenario where if one prop is present, another prop becomes required, but unnecessary if the first prop is absent. props: { url: { type ...

Injecting a JavaScript object into an HTML string

I am facing an issue with a JavaScript variable I have, which points to a specific DOM element that I want to display somewhere else within the DOM structure. Here is how it is defined: var salesRep = $("ul.map").attr("id","1"); My goal is to pass this v ...

An efficient method for removing a column using JavaScript

Hello, I'm seeking assistance with the following code snippet: $(document).on('click', 'button[id=delete_column]', function () { if (col_number > 1) { $('#column' + col_number).remove(); $('#col ...

Navigating Paths in Real-time with Javascript - Node.js

When working with PHP, dynamic routing can be achieved by defining classes and methods like: class Route { public function homePage () { echo 'You are on the home page' } public function otherPage () { echo 'You are on so ...

Is it obligatory to reply with status code 200 in Express?

Is it required to explicitly include a status 200 code in the response or is it set automatically? response.json({ status: 'OK', }); vs. response .status(200) .json({ status: 'OK', }); Upon testing the route in my browser, ...

What is the most effective approach for managing two distinct ajax calls within a Laravel application?

I am working on a page with two separate ajax calls (using Laravel). The first call triggers the second one, but the options for the second ajax are in a select box. Here is my current solution: public function getCategoryAjax(Request $request) { $pr ...

What are some best practices for utilizing `element.offsetParent` in HTML SVG elements?

I'm currently updating some JavaScript code that relies on the .offsetParent property. The recent changes in the application involve the use of SVG elements, which are causing issues with the JavaScript as mySvgElement.offsetParent always returns unde ...

Verify if spacebar is pressed and then use jQuery to add a hashtag with multi-language support

I am attempting to use jQuery to add a hashtag (#) after the user types and presses space. I have created a demonstration on CodePen. In this demo, when you type something like (how are you), the JavaScript code will change it to (#how #are #you). To ach ...

Google Analytics in Next.js Missing Page Title Configuration

I recently set up Google Analytics on my Next.js website, but I'm encountering a strange issue where the analytics are not detecting my webpages and showing as (not set). Everything else seems to be functioning properly. I've double-checked that ...

The Vue template syntax utilizes double curly braces for incrementing values within must

Embarked on learning Vue.js recently and I am intrigued by the unusual behavior in my simple code. I cannot seem to figure out what is going wrong. I am attempting to increment a counter inside mustache syntax, but something strange is happening with this ...

React Weather App: difficulties entering specific latitude and longitude for API requests

I have successfully developed an app that displays the eight-day weather forecast for Los Angeles. My next objective is to modify the longitude and latitude in the API request. To achieve this, I added two input fields where users can enter long/lat values ...