No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Problem with the same component displayed twice

    Help
    2
    6
    1937
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tonpereira last edited by tonpereira

      Hello, my name is Everton!
      I’m having a problem, I’m developing a project, in which I use the same component two in the same .vue file
      In this component that was created, I put a mask in a field by jquery.
      In the second view of the component the mask does not work in the field, only in the first view.
      I’ll leave a photo and part of the code here to see if they can help me!

      the problem is the field # of the CPF that appears in the component shown above and below, are the same components but the top is masked and the bottom does not apply the mask

      the component is the <form-cadastro></form-cadastro>

      0_1507149654077_erro.png

      https://pastebin.com/raw/FwradFpJ

      <script>
      import FormCadastro from '../../components/formCadastro/formCadastro.vue'
      
      export default {
        data () {
          return {
            progress: 40,
            checked: false,
            disable: {
              check: true
            }
          }
        },
        components: { FormCadastro },
      ....
      </script>
      
      <template>
      ....
      <div id="interessado">
            <h4 class="text-primary titleGeral">Identificação do Interessado</h4>
            <hr />
            <form-cadastro></form-cadastro>
          </div>
          <div>
            <q-checkbox v-model="checked" label="Informar representante legal caso o interessado não possa comparecer" 			:disable="disable.check"/>
          </div>
          <div id="representante" v-show="checked === true">
            <h4 class="text-primary titleGeral">Identificação do Representante Legal do interessado</h4>
            <hr />
            <form-cadastro></form-cadastro>
      ...
      </template>
      1 Reply Last reply Reply Quote 0
      • L
        leon last edited by

        Can you put the code of jquery mask add here ?

        T 1 Reply Last reply Reply Quote 0
        • T
          tonpereira @leon last edited by

          @leon

          Hello, I use this plugin in jquery to make the mask,

          of the change of my first field I check what kind of document that was selected and apply the mask for that type of document in the next field.

          https://igorescobar.github.io/jQuery-Mask-Plugin/

          ...
          methods: {
              TPO_DOC () {
                if (this.TIPODOCTO === 'Selecione') {
                  this.labelNdoc = 'N° do *'
                  this.cpfcnpj = ''
                  this.nomecompleto = ''
                  this.formValid.UserEncontrado = ''
                  this.formValid.userValido = ''
                  this.disable.cpfcnpj = true
                }
                if (this.TIPODOCTO === 'CPF') {
                  this.labelNdoc = 'N° do CPF *'
                  this.disable.cpfcnpj = false
                  this.maxlength = 14
                  $('#cpfcnpj :input').mask('000.000.000-00', {reverse: false})
                }
                if (this.TIPODOCTO === 'CNPJ') {
                  this.labelNdoc = 'N° do CNPJ *'
                  this.disable.cpfcnpj = false
                  this.maxlength = 18
                  $('#cpfcnpj :input').mask('00.000.000/0000-00', {reverse: false})
                }
              },
          ......
          L 1 Reply Last reply Reply Quote 0
          • L
            leon @tonpereira last edited by

            3 Suggestions

            • CamelCase method name wiki camel case doc / Vue doc
              tipoDoc instaed of TPO_DOC

            • The way you are haldling your logic can be done whit computeds. Read this vue doc

            • And your mask question probaly is because you are using ID, if you use a class instead will probaly work.
              BTW, you can use computed and a pure JS lib to solve it too whitout jquery.

            1 Reply Last reply Reply Quote 0
            • L
              leon last edited by

              Here https://codesandbox.io/s/8qn593m20

              1 Reply Last reply Reply Quote 0
              • T
                tonpereira last edited by

                I got it sorted, thanks!

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post