EasyUI Forum
May 14, 2024, 12:19:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: how to trigger tooltip showEvent on textbox focus  (Read 5257 times)
fengdie
Jr. Member
**
Posts: 87


View Profile Email
« on: October 24, 2018, 07:51:44 PM »

run this example

Code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>EasyUI for Vue</title>
  <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">
  <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/color.css">
  <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/vue.css">
    <script src="https://www.jeasyui.com/node_modules/vx-easyui/vue.min.js"></script>
    <script src="https://www.jeasyui.com/node_modules/vx-easyui/babel-polyfill.js"></script>
    <script src="https://www.jeasyui.com/node_modules/vx-easyui/vx-easyui-min.js"></script>
    <script src="https://www.jeasyui.com/node_modules/vx-easyui/babel.min.js"></script>
    <style type="text/css">
        body{
            padding: 20px;
        }
        h2{
            margin: 0 0 20px 0;
        }
        .mycontainer{
            min-width: 700px;
        }
    </style>
</head>
<body>
      <div id="app"></div>
    <script type="text/babel">
      var demovalidate2={
        template: `
  <div>
    <button @click="dialogClosed=false">打开</button>
    <Dialog ref="d1" bodyCls="f-column" :dialogStyle="{width:'700px',height:'550px'}" title="标题" :closed="dialogClosed" @open="onDialogOpen">
  <Form ref="form" :model="user" :rules="rules" @validate="errors=$event">
<div style="margin-bottom:20px">
  <Label for="name" align="top">Name:</Label>
  <TextBox ref="name" inputId="name" name="name" v-model="user.name" v-Tooltip="getTipOpts('name')"></TextBox>
</div>
  </Form>
  <p>{{user}}</p>
  </Dialog>
  </div>
`,
       
  data() {
    return {
      dialogClosed: true,
      user: {
        name: null
      },
      rules: {
        name: ["required", "length[5,10]"]
      },
      errors: {}
    };
  },
  methods: {
    onDialogOpen() {
            this.$nextTick(() => {
this.$refs.name.focus()
                this.$refs.form.validate()
            })
    },
    getError(name) {
      return this.errors[name] && this.errors[name].length
        ? this.errors[name][0]
        : null;
    },
    hasError(name) {
      return this.getError(name) != null;
    },
    getTipOpts(name) {
      return {
        content: this.getError(name),
        closed: !this.hasError(name),
        position: "right"
      };
    },
  }
      }
      var app = new Vue({
        el: '#app',
        template: `<demovalidate2 class="mycontainer"></demovalidate2>`,
        components: {
          demovalidate2:demovalidate2       }
      })
    </script>
<style>
.error {
  color: red;
  font-size: 12px;
  margin: 4px 0;
}
</style>
</body>
</html>
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: October 25, 2018, 06:17:19 PM »

Please try this code.
Code:
getTipOpts(name) {
  return {
    showEvent: 'mouseenter focusin',
    hideEvent: 'mouseleave focusout',
    content: this.getError(name),
    closed: !this.hasError(name),
    position: "right"
  };
}
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!