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

    How to use custom directives

    Framework
    1
    4
    1080
    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.
    • A
      azeredobr last edited by

      When I use directive in quasar component, its doesn’t work.

      How I need to do? Or where I can find any exemplo of it?

      In the “simple input”, works ok.

      Thanks!

      <div id=“q-app”>
      <q-input v-focus type=“text” value=“123”></q-input>
      <input v-focus2 type=“text” value=“1234”>
      </div>

      new Vue({
      el: ‘#q-app’,
      directives: {
      focus: {
      inserted: function(el) {
      el.focus()
      }
      },
      focus2: {
      inserted: function(el) {
      el.focus()
      }
      }
      }
      })

      1 Reply Last reply Reply Quote 0
      • A
        azeredobr last edited by

        Sorry, the directive works. If I add an alert(‘test’) in the focus directive. The el.focus that doesn’t works with on quasar components.

        1 Reply Last reply Reply Quote 0
        • A
          azeredobr last edited by

          I can do this, but I think it’s not the better approach, but works

          el.getElementsByClassName(“q-field__native”)[0].focus()

          1 Reply Last reply Reply Quote 0
          • A
            azeredobr last edited by

            https://jsfiddle.net/s0zmL59a/2/

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