Announcement

Collapse
No announcement yet.

Fetch member name in input field

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Fetch member name in input field

    Hi glennrocksvb , Hi all !

    I'm looking at other template files, the private message one and the advanced search results for example, and I have a hard time figuring out how to have the same functionality as there, that allow an input field to show the list of users that seems to match the characters typed in the input field. The same way it works for tagging people in a post for example.

    Any help on that subject ?

    To test things it would be in a simple widget, with just an input field and a button, nothing else

    Thanks in advance

    #2
    When you try the existing functionality, open the dev tools and observe the AJAX call in the Network > XHR tab. Copy parts of the AJAX URL and then search for it in the JS files.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


      #3
      I already did that and I know where that lead, but I was wondering if they're was a known way of implementing it in templates syntax

      Comment


        #4
        You'd implement it using pure JS and AJAX. No template syntax needed.
        Helpful? Donate. Thanks!
        Buy me a coffeePayPal QR Code
        Fast VPS Host for vBulletin:
        A2 Hosting & IONOS

        Comment


          #5
          Originally posted by glennrocksvb View Post
          You'd implement it using pure JS and AJAX. No template syntax needed.
          Thanks, I'll look into that

          Comment


            #6
            Managed to get it working (thanks to an old answer of you on vb.org ) but I have an error that I don't understand, my code :

            Code:
            <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
            <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
            {vb:js insert_here, js/autocomplete.js}
            
            <input type='text' name='friend_name' id='friend_name' class='searchFields_author textbox'>
            <script>
            var userAutocomplete = new vBulletin_Autocomplete($('#friend_name'), {
                apiClass: "user",
                maxItems:1,
                containerClass: "searchFields_author"});
            </script>
            This does work, it fetches the username,insert it in the input, allow to remove it or add multiples (without the maxItems parameter of course).
            But I have the "Working" indicator stuck and this error :

            Code:
            autocomplete.js?v=542:11 Uncaught TypeError: Cannot read property 'menu' of undefined
                at HTMLInputElement.open (autocomplete.js?v=542:11)
                at e.<computed>.<computed>._trigger (jquery-ui.min.js:6)
                at e.<computed>.<computed>.__response (jquery-ui.min.js:7)
                at e.<computed>.<computed>.__response (jquery-ui.min.js:6)
                at e.<computed>.<computed>.n (jquery-ui.min.js:6)
                at e.<computed>.<computed>.__response (jquery-ui.min.js:7)
                at e.<computed>.<computed>.__response (jquery-ui.min.js:6)
                at e.<computed>.<computed>.<anonymous> (jquery-ui.min.js:7)
                at d (jquery-1.12.4.min.js:2)
                at Object.success (autocomplete.js?v=542:11)
            It only does this, when the username is found, with a random username not matching anything in the database, I have no error.

            Any idea what could it be ?

            Comment


              #7
              Hard to tell without seeing the error myself and debugging the code.
              Helpful? Donate. Thanks!
              Buy me a coffeePayPal QR Code
              Fast VPS Host for vBulletin:
              A2 Hosting & IONOS

              Comment


                #8
                Originally posted by glennrocksvb View Post
                Hard to tell without seeing the error myself and debugging the code.
                Stock Vbulletin 5.4.2, nothing else in the page than the code posted above and than the error posted above, would you take a look if I gave you access to the admin ?
                (But I'm pretty sure the error would be the same everywhere)

                Comment

                Users Viewing This Page

                Collapse

                There is 1 user viewing this forum topic.

                • Guest Guest

                Latest Posts

                Collapse

                Working...
                X
                Searching...Please wait.
                An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

                Please push the back button and reload the previous window.'
                An unexpected error was returned: 'Your submission could not be processed because the token has expired.

                Please push the back button and reload the previous window.'
                An internal error has occurred and the module cannot be displayed.
                There are no results that meet this criteria.
                Search Result for "|||"