Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

focus on child components on single page applications - 1

<template>
  <div>
    <button type="button" @click="focusChildInput">Focus to Input</button>
    <child />
  </div>
</template>

<script>
import child from './child.vue';

export default {
  name: 'app',
  components: { child },
  methods: {
    focusChildInput() {
      this.$root.$emit('focusChildInput');
    },
  },
};
</script>
Comment

focus on child components on single page applications - 2

<template>
  <div>
    <input type="text" ref="childInput" />
  </div>
</template>

<script>
export default {
  name: 'child',
  mounted() {
    this.$root.$on('focusChildInput', () => this.$refs.childInput.focus());
  },
};
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: empty donut chart chart js 
Javascript :: saving some fields of an instance in sequelize 
Javascript :: Make a ReactNative component take the height and width of the current window 
Javascript :: go back to screen with params react native 
Javascript :: FTP Get a directory listing of the current 
Javascript :: nestjs openapi yaml file 
Javascript :: matrix addition in javascript 
Javascript :: toast width match parent 
Javascript :: Creates an Express application 
Javascript :: register js in viewyii2 
Javascript :: jquery confirm dialog yes no 
Javascript :: app script with success handler response null 
Javascript :: on click a button triger a tab bootstrap 5 
Javascript :: why promise goes to microtask and settimeout to browser api 
Javascript :: make a backend server in node 
Javascript :: array min value in vmware_vro 
Javascript :: check if device is in dark mode js 
Javascript :: get current user moralis web3 login 
Javascript :: mongoose connecting directly rather than tunnel 
Javascript :: html how to remove class with js 
Javascript :: jquery redirect to another page on radio button 
Javascript :: remove all special characters online 
Javascript :: js dom after selectors 
Javascript :: map and get last child in js 
Javascript :: how to use window.alert in javascript 
Javascript :: javascript string to date format dd/mm/yyyy 
Javascript :: if conprimido js 
Javascript :: Register post meta of sidebar in wordpress 
Javascript :: format file using jq input curl 
Javascript :: javascript copy input value to clipboard 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =