I'm using vuetify to design a 'card' component.
I have a parent div with a child button. Now, when I click the button, the ripple effect on the div is triggered.
How can I fix this?
<template>
<div>
<v-card v-ripple="true">
<h3>
<v-card-title>{{ title }}</v-card-title>
</h3>
<v-layout row>
<v-flex grow>
<v-card-text>
{{ plaats }}
<br />
{{ sub_title }}
</v-card-text>
</v-flex>
<v-flex shrink>
<v-card-actions>
<v-btn small color="blue" fab>
<v-icon medium color="white">mdi-calendar</v-icon>
</v-btn>
<v-btn small color="green" fab>
<v-icon medium color="white">mdi-calendar-check</v-icon>
</v-btn>
<v-btn small color="red" fab>
<v-icon medium color="white">mdi-calendar-remove</v-icon>
</v-btn>
</v-card-actions>
</v-flex>
</v-layout>
</v-card>
</div>
</template>
The solution was indeed Event.stopPropagation but I had to add it to the mousedown action.
So #mousedown.stop and then add your function with #click.stop="null" as #Frank mentioned before.
Note #mousedown event will not fire on mobile, thus we also need to
add #touchstart.
Codepen
<v-list>
<v-list-tile :ripple="true" #click="">
<v-list-tile-action>
<v-btn
#click.stop=""
#mousedown.stop=""
#touchstart.stop=""
>Click</v-btn>
</v-list-tile-action>
<v-list-tile-content class="pl-5">
Click tile
</v-list-tile-content>
</v-list-tile>
</v-list>
You're looking for Event.stopPropagation. Add #click.stop="null" to your button(s). Of course you can/should replace null with your own method.
if your vuetify css is separate, not in your app.js,
the solution that worked for me is to put the app.js script outside the body, when it is inside the js loads first than the vuetify css.
<!-- ripple error occurs randomly -->
<script src="{{ URL::asset('js/vLib.js') }}" defer></script>
</body>
<!-- Should be outside the body -->
</body>
<script src="{{ URL::asset('js/vLib.js') }}" defer></script>
Related
I am using the Vuetify Tooltip component. I want to display the tooltip icon right after the label. I am not sure how can I do that. Please help me figure that out. Right now the icon appears as in image 1
I want it right after the information text.
<v-container fluid>
<v-layout row wrap>
<v-flex xs11 md6 class="add-col-padding-right">
<v-text-field
label='Information'
v-model='dummy.info'
>
</v-text-field>
</v-flex>
<v-flex xs1 md6 class="add-col-padding-left">
<v-tooltip attach>
<a href='javascript:void(0);' slot="activator">
<i class="material-icons icon-black">
info
</i>
</a>
<span>Please enter the user information correctly.</span>
</v-tooltip>
</v-flex>
</v-layout>
</v-container>
Update
<v-text-field
label='Information'
v-model='dummy.info'
>
<template v-slot:append>
<v-tooltip bottom>
<template #activator="{on}">
<v-icon v-on="on">mdi-pencil</v-icon>
</template>
</v-tooltip>
</template>
</v-text-field>
Update 2
If I put v-tooltip inside then it doesn't work. I want the icon to after right after information.
<v-tooltip right>
<v-icon slot="activator" dark color="primary">info</v-icon>
<span>Please enter the user information correctly.</span>
</v-tooltip>
<v-text-field
label='Information'
v-model='dummy.info'
>
</v-text-field>
Use the append slot for the v-text-field component. Inside of the v-text-field component, this should work for you:
<template v-slot:append>
<v-tooltip bottom>
<template #activator="{on}">
<v-icon v-on="on">mdi-pencil</v-icon>
</template>
<v-tooltip>
</template>
Edit: You may not have material design icons configured with Vuetify like I do.
Try this, sorry about the confusion.
<v-text-field>
<template v-slot:append>
<v-tooltip bottom>
<template v-slot:activator="{on}">
<v-btn v-on="on">test</v-btn>
</template>
<span>Hello World</span>
</v-tooltip>
</template>
</v-text-field>
This should put a v-btn at the end of the text field with a tooltip that reads 'Hello World'
I'm making a web application which contains a navigation drawer, the intention was that the navigation drawer was open by default, and if the screen size changes to a smaller one it should close, if it is changed back to the big screen size it should reopen, but it's currently not working.
i have tried using the break points($vuetify.breakpoint.lgAndUp) and v-model but it doesn't seems to work.
<template>
<!--Start of template layaout-->
<v-layout wrap row>
<!--End of template layout-->
<v-app-bar color="grey lighten-2" light height="80" app clipped-left>
<v-app-bar-nav-icon x-large #click.stop="draw = !draw"></v-app-bar-nav-icon>
<v-img
src="http://logo-load.com/uploads/posts/2016-02/1455472802_logo.png"
lazy-src="http://logo-load.com/uploads/posts/2016-02/1455472802_logo.png"
aspect-ratio="1"
max-width="60"
max-height="60"
class="appTitle"
#click="pushToken('Home')"
></v-img>
<v-toolbar-title class="text-uppercase">
<span #click="pushToken('Home')"> Tools</span>
</v-toolbar-title>
<!--Spacer to keep buttons to the right side-->
<v-spacer></v-spacer>
<!--Apps menu button-->
<!--Apps menu start-->
<v-menu offset-y max-width="200" min-width="200">
<template v-slot:activator="{ on: menu }">
<v-tooltip bottom>
<template v-slot:activator="{ on: tooltip }">
<v-btn text v-on="{ ...tooltip, ...menu }">
<v-icon large>apps</v-icon>
</v-btn>
</template>
<span>Applications</span>
</v-tooltip>
</template>
<v-list>
<v-list-item v-for="(app, index) in apps" :key="index" class="appDecor">
<v-btn :color="app.color" dark>{{app.title}}</v-btn>
</v-list-item>
</v-list>
</v-menu>
<!--Apps menu end-->
<!--Menu template for list menu-->
</v-app-bar>
<!--Log out Dialog-->
<v-dialog v-model="dialog" max-width="350px" transition="dialog-transition">
<v-card>
<v-card-title>Are you sure you want to exit?</v-card-title>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="info" #click="logOut()">yes</v-btn>
<v-spacer></v-spacer>
<v-btn color="info" #click="dialog = false">no</v-btn>
<v-spacer></v-spacer>
</v-card-actions>
</v-card>
</v-dialog>
<!--Dialog-->
<!--Nav drawer start-->
<v-navigation-drawer
v-model="draw"
color="grey lighten-2"
absolute
:clipped-left="$vuetify.breakpoint.lgAndUp"
>
<v-layout row wrap>
<v-container grid-list-xs>
<v-list dense nav>
<v-list-item v-for="item in items" :key="item.id" link>
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<span #click="pushToken(item.link)">{{ item.param }}</span>
</v-list-item-content>
</v-list-item>
</v-list>
</v-container>
</v-layout>
<template v-slot:append>
<v-btn #click="dialog = true" block class="my-5">
<v-icon left>exit_to_app</v-icon>Log out
</v-btn>
</template>
</v-navigation-drawer>
<!--Nav drawer end-->
</v-layout>
</template>
i expected the nav drawer being open by default, closing o smaller screens and reopening if changing the screen size to a bigger one, but the actual result is, the drawer open by default and keeps open if the screen size changes(and also a screen overlay is displayed on small screen),if i close it manually it won't open itself when changing between screen sizes.
If you want to find bugs, you should give the relevant code which controls the nav drawer changes.
Simple solution: v-show and change nav drawer's display
for examle:
`
<template>
<v-app>
<v-content>
<div v-show='is_hide_text' ref='text'>
<p>some text</p>
</div>
<button #click='hide_content'>hide_content</button>
</v-content>
</v-app>
</template>
<script>
import HelloWorld from './components/HelloWorld';
export default {
name: 'App',
data: () => ({
//
}),
computed:{
is_hide_text(){
return this.$vuetify.breakpoint.mdAndUp
}
},
methods:{
hide_text(){
this.$refs['text'].style.display = 'none'
}
}
};
</script>
`
I have a button that is the activator for a dialog in my template. But I also want to use a tooltiop with the button. (Said otherwise, when I hover over the button I'd like to see the v-tooltip and when I click the button I'd like to open the dialog.)
I've tried to use the "append" slot on the tooltip but no success. When I add the append slot, the button completely vanishes from the rendered page.
Is it even possible to use a v-tooltip with a v-dialog in veutify?
This is what I have that does not work.
<script src="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.js"></script>
<link href="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<v-app>
<v-dialog v-model="showAddPopup" persistent max-width="600px">
<v-tooltip slot="append" bottom>
<v-btn slot="activator" absolute fab dark left color="primary" #click="showPopup=true">
<v-icon dark>add</v-icon>
</v-btn>
<span>Tooltip</span>
</v-tooltip>
<app-add-new-evaluator-modal #closePopup="closePopup($event)" #submit="addNewEvaluator" />
</v-dialog>
</v-app>
The Vuetify docs explain how to do this, but you'll find it in the Menu Component:
https://vuetifyjs.com/en/components/menus#menu-with-activator-and-tooltip
Here's a simple example which opens a dialog with a button that has a tooltip:
<v-dialog>
<template #activator="{ on: dialog }">
<v-tooltip>
<template #activator="{ on: tooltip }">
<v-btn v-on="{ ...tooltip, ...dialog }">Button</v-btn>
</template>
<span>Tooltip text</span>
</v-tooltip>
</template>
<v-card>
Dialog content
</v-card>
</v-dialog>
Thanks #Traxo. All I had to do was add the slot="activator"to both components for it to work.
⚠️ ⚠️ problem with this solution, menu gets closed when you click anywhere on it ⚠️ ⚠️
Use this only if you can afford it to close anywhere you click:
<template>
<v-menu>
<template v-slot:activator="{ on: menu, attrs }">
<v-tooltip bottom>
<template v-slot:activator="{ on: tooltip }">
<v-btn v-bind="attrs" v-on="{ ...tooltip, ...menu }" fab>
<v-icon>mdi-account-multiple-plus</v-icon>
</v-btn>
</template>
<span>tooltip</span>
</v-tooltip>
</template>
<v-card>
<v-card-title class="headline grey lighten-2">
title
</v-card-title>
<v-card-text>
text
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text #click="dialog = false">
I accept
</v-btn>
</v-card-actions>
</v-card>
</v-menu>
</template>
I'm using Vuetify and to create multiple styled v-card, each card should contain link to a target but only by clicking the card's internal title or image. The problem is that I'm looping over my array of object's and wrapping each v-card with <router-link> so the entire card is clickable. here is the code:
<router-link v-for="recipe in recipes" :key="recipe.title" :to="{path: `recipe/${recipe.title}`}">
<v-card>
<v-img :src="require('../assets/foodpic.jpg')" aspect-ratio="2.75"></v-img>
<v-card-title primary-title>
<div>
<h3 class="headline mb-0">{{ recipe.title }}</h3>
</div>
</v-card-title>
<v-card-actions>
<v-btn flat color="orange" disabled>Share</v-btn>
<v-btn flat color="orange">Explore</v-btn>
</v-card-actions>
</v-card>
</router-link>
i found a way to attach router link to specific element using tags but that only allows me to connect single html element and here i want to use the same link on multiple elements.
any idea how can i modify this code so only the v-img and v-card-title will be linked to the recipe?
hope it works for you
<v-card v-for="recipe in recipes" :key="recipe.title">
<v-img :src="require('../assets/foodpic.jpg')" aspect-ratio="2.75"
:to="{path: `recipe/${recipe.title}`}"></v-img>
<v-card-title primary-title :to="{path: `recipe/${recipe.title}`}">
<div>
<h3 class="headline mb-0">{{ recipe.title }}</h3>
</div>
</v-card-title>
<v-card-actions>
<v-btn flat color="orange" disabled>Share</v-btn>
<v-btn flat color="orange">Explore</v-btn>
</v-card-actions>
</v-card>
i ended up setting it like this:
<v-card v-for="recipe in recipes" :key="recipe.title">
<router-link :to="{path: `recipe/${recipe.title}`}">
<v-img :src="require('../assets/foodpic.jpg')" aspect-ratio="2.75"></v-img>
</router-link>
<v-card-title primary-title>
<div>
<router-link :to="{path: `recipe/${recipe.title}`}">
{{ recipe.title }}
</router-link>
</div>
</v-card-title>
<v-card-actions>
<v-btn flat color="orange" disabled>Share</v-btn>
<v-btn flat color="orange">Explore</v-btn>
</v-card-actions>
</v-card>
While making list screen with v-list.
I stuck scrolling v-list-title items.
I'm using VueJS and vuetifyjs.
My code snip is at below.
https://codepen.io/badsaarow/pen/aaRaxe?editors=1010
My aim is that toolbar area is fixed, and only v-list-titles are scrollable.
<div id="app">
<v-app id="inspire">
<v-container fluid grid-list-lg>
<v-layout row wrap>
<v-flex xs12 sm12 md6>
<v-card>
<v-toolbar color="light-blue" light extended>
<v-btn
fab
small
color="cyan accent-2"
bottom
right
absolute
#click="dialog = !dialog"
>
<v-icon>add</v-icon>
</v-btn>
<v-toolbar-title slot="extension" class="white--text">user list</v-toolbar-title>
<v-spacer></v-spacer>
</v-toolbar>
<v-list two-line>
<v-list-tile
v-for="user in users"
avatar
#click=""
>
<v-list-tile-avatar>
<v-icon :class="iconClass">face</v-icon>
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title>{{ user.lastName }}{{ user.firstName }}</v-list-tile-title>
<v-list-tile-sub-title>{{ user.name }}</v-list-tile-sub-title>
</v-list-tile-content>
<v-list-tile-action>
<v-btn icon ripple>
<v-icon color="grey lighten-1">info</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
</v-list>
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-app>
</div>
Try to add following CSS to make v-list-titles scrollable.
.v-list {
height: 300px;
overflow-y: auto;
}
We need to specify a fixed height for our DOM object, and once we set the overflow-y attribute as auto. A scroll bar will show up once content has bigger length than parent.
Here is the modified version, have a try.
Just add the fixed prop to v-toolbar, as so:
<v-toolbar color="light-blue" light extended fixed>
See here for updated pen