Is there a way to activate the <select>
or <b-form-select>
dropdown menu when hovering over it, without relying on JQuery or any third-party plugin except for Vue.js?
Is there a way to activate the <select>
or <b-form-select>
dropdown menu when hovering over it, without relying on JQuery or any third-party plugin except for Vue.js?
Based on my understanding, it seems like you are looking to toggle the visibility of <b-form-select>
using the mouseover
and mouseleave
events. If this is correct, I have a few recommendations :
mouseover
and mouseleave
events. You can directly employ the mouse events by adding the native
attribute to the element itself. However, keep in mind that once the dropdown is hidden, there may not be a straightforward way to make it reappear on mouseover.v-show
directive to show/hide the dropdown. This allows for easy manipulation of the visibility based on the mouse events.View the Demo :
new Vue({
el: '#app',
data() {
return {
selected: null,
isVisible: true,
options: [
{ value: null, text: 'Please select an option' },
{ value: 'a', text: 'This is First option' },
{ value: 'b', text: 'Selected Option' },
{ value: { C: '3PO' }, text: 'This is an option with object value' },
{ value: 'd', text: 'This one is disabled', disabled: true }
]
}
},
methods: {
onOver() {
this.isVisible = true;
},
onLeave() {
this.isVisible = false;
}
}
})
.wrapper-div {
height: 20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8cac7c7dcdbdcdac9d885deddcde89a869a9a8698">[email protected]</a>/dist/bootstrap-vue.js"></script>
<link rel="stylesheet" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c8aaa7a7bcbbbcbaa9b8e5bebdad88fae6fafae6f8">[email protected]</a>/dist/bootstrap-vue.css"/>
<div id="app">
<div class="wrapper-div" @mouseover="onOver" @mouseleave="onLeave">
<b-form-select
v-model="selected"
:options="options"
v-show="isVisible">
</b-form-select>
</div>
</div>
When using this solution, the outcome is akin to triggering the select option as if it had been clicked on (though not exactly the same...)
<template>
<select ref="mySelect" @mouseenter="hover(true)" @mouseleave="hover(false)" :size="size">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
</template>
<script>
import {ref} from 'vue';
export default {
name: "Test",
setup(){
const mySelect = ref();
const size = ref('0');
return {mySelect, size}
},
methods: {
hover(val) {
this.size = val ? this.mySelect.length.toFixed(0) : '0';
}
}
}
</script>
I'm searching for a regex pattern that can identify numbers within the range of 0.5 to 24, excluding cases like 0,5 or 22,5. The current pattern I'm using is: /^(([0-9]|1[0-9]|2[0-3])([^,])(\.(0|5)))$/ Despite having excluded the comma ,, ...
Want to transform the date time format using momentjs 2017-02-01T00:00:00.000Z into 02-2017 ( month-year ) Looking for a way to change the date format to display only month-year using momentjs? I attempted it like this: var MnthYr = moment(2017-02-01 ...
When presented with two arrays of options, users must select an option from each array. ==> first array: [ orange, green, yellow ] ==> second array: [ orange, green, yellow ] The challenge is to update the second array based on the user's sele ...
Recently, I attempted to integrate Redux into my React application. I created a container called SignIn that instantiates a mapDispatchToProps and connects it to the component. The SignIn component renders a sub-component called SignInForm (code provided ...
I seem to be overlooking something obvious, but here's the issue - I am receiving a PNG from a Mapbox call with the intention of saving it to the file system and then serving it to the client. I have successfully made the call, received raw data as a ...
Can you share your insights on the best practices for sorting objects in expressjs + mongodb(mongoose) web applications? Imagine we have a Product model with four attributes: var ProductSchema = new mongoose.Schema({ name: String, // "Summer T-sh ...
I have a simple dropdown menu in my HTML code. HTML <select name="breed" onchange="breedChanged()"> <?php while ($row = gdrcd_query($result, 'fetch')){ ?> <option value="<?php echo $row['id_breed']; ?& ...
I'm in the process of integrating PayPal into my website using their REST API. My goal is to allow users to input the amount they want to deposit. While I can obtain the total during payment creation, I'm unsure how to smoothly pass it to the exe ...
I created a button that successfully opens, but I am struggling to figure out how to close it. Can someone assist me with this? Additionally, I have one more query: How can I remove the border when the button is clicked? document.getElementById("arrowb ...
I need assistance to access the value of a nested object within an array. I have the _id of the parent object and the _id of the child object in the array, but I am struggling to get the value of "solvedOn" in order to toggle a checkbox behavior. Here is ...
Currently, I am in the process of developing a VueJS 3 application using Vite and Bootstrap 5.2. I am interested in utilizing breakpoint mixins in my components but I am struggling to do so without having to import the bootstrap .scss file into each compon ...
Copied from the official AngularJS 1 documentation: To make a binding optional, simply add ?: <? or <?attr. What are the differences between the optional and non-optional one-way bindings? I can't seem to find the dissimilarities for the op ...
I am trying to set up a conditional rendering for a v-alert if the login response code is 401 Unauthorized. Here is how I have defined the alert: <v-alert v-if="this.show" type="error">Invalid email and/or password.</v-alert> Within the data ...
Recently, I integrated a Slide in menu script on my website using a Slide in menu script. After following all the instructions provided, the menu started working flawlessly on Chrome and Safari browsers. However, my main goal was to make it function on Fir ...
Could someone shed light on why my jQuery/JavaScript code runs with an unexpected flurry of ajax calls instead of at a steady 1-per-second rhythm? var i = 0, l = data.length; function geocode() { $.getJSON( 'https://maps.googleapis.com/maps/api ...
Is there a way to restrict the type of property of a class in an aliased conditional expression? Short: I am trying to perform a type narrowing check within a class method, like this._end === null && this._head === null, but I need to assign the r ...
After implementing dynamic functionality from jQuery in my code, I encountered an issue where if I navigate back one page and then return to the original page containing the added elements, they seem to trigger twice upon clicking. To troubleshoot, I incl ...
I am currently facing an issue while trying to retrieve an array from a JSON request using Postman. In my Node.js application, I am able to read all values from req.body except for the array. When attempting to access the array, I only receive the first va ...
I am trying to retrieve specific information from this source: https://i.sstatic.net/g1wDj.png This information is crucial for fetching data from a database using a primary key. However, extracting this value has proven to be quite challenging. Upon docu ...
I'm currently facing an issue with transferring an array from a server to a web page through Jinja2 in Google App Engine. Despite my efforts, I'm struggling to make the array readable by my jQuery code. This is all new to me as it's my first ...