How to make jQuery autocomplete do a search () when a user falls into submit

As my last post indicates - How would I crop input to a jQuery autocomplete field? . I decided to ask a new question, and not continue editing it.

I currently have jQuery ui autocomplete 1.8 (or so) working quite well, except for one thing. If the user simply enters the (valid) name and sends the requests, the search automatically ends, so the associated value is never captured or assigned in the input field. This, of course, is a problem. Reading the documentation, this means that I could use the jQuery method search()to overcome this. However, I'm struggling to get it to work. I tried to make a call search()in the onblur event of the text input, as well as in the onclick event of the submit button, but to no avail - whenever I click submit, I have no value for the input field. The code:

<form action = "<?php echo $this->URL();?>" method="post">
    <fieldset>
        <ol>
            <li>
                <label for="Resource">Resource</label>
                <input id="Resource" name="Resource" class="text" type="text"  value="" onblur="jQuery('#Resource').search();"/>
            </li>
        </ol>
    </fieldset>
    <fieldset class="submit">
        <input id="Submit" name="Submit" type="Submit" class="Submit" value ="Submit" onclick = "jQuery('#Resource').search();"/>
    </fieldset> 
</form>

So what exactly am I doing wrong?

+1
2

- change.

: jQuery - ,

+2

, search() , . :

    <input id="Submit" name="Submit" type="Submit" class="Submit" value ="Submit" onclick="jQuery('#Resource').autocomplete('search');"/>

, , , . , search() , -, .

0

Source: https://habr.com/ru/post/1756173/


All Articles