Когда я пытаюсь это сделать, он работает как положено: после двух символов он показывает совпадающие записи.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="development-bundle/jquery-1.6.2.js"></script>
<script src="development-bundle/ui/jquery.ui.core.js"></script>
<script src="development-bundle/ui/jquery.ui.widget.js"></script>
<script src="development-bundle/ui/jquery.ui.position.js"></script>
<script src="development-bundle/ui/jquery.ui.autocomplete.js"></script>
<script type="text/javascript">
$( document ).ready( function() {
var data = [ 'John', 'Jack', 'Joe', 'Lisa', 'Barbara' ];
$( "#name" ).autocomplete({
source: data,
minLength: 2
});
});
</script>
</head>
<body>
<form>
<table>
<tr><td>Name:</td><td><input type="text"
id="name" name="name" /></td></tr>
</table><br />
<input type="submit" value="OK"/>
</form>
</body>
</html>
Это ведет себя иначе: после двух символов всегда отображаются все записи?
Что не так со вторым примером?
#!/usr/local/bin/perl
use warnings;
use 5.014;
use utf8;
use Mojolicious::Lite;
get '/eingabe' => sub {
my $self = shift;
$self->render( 'eingabe' );
};
get '/search_db' => sub {
my $self = shift;
$self->render( json => [ 'John', 'Jack', 'Joe', 'Lisa', 'Barbara' ] );
};
app->start;
__DATA__
@@ eingabe.html.ep
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="/development-bundle/jquery-1.6.2.js"></script>
<script src="/development-bundle/ui/jquery.ui.core.js"></script>
<script src="/development-bundle/ui/jquery.ui.widget.js"></script>
<script src="/development-bundle/ui/jquery.ui.position.js"></script>
<script src="/development-bundle/ui/jquery.ui.autocomplete.js"></script>
<script type="text/javascript">
$( document ).ready( function() {
$( "#name" ).autocomplete({
source: '/search_db',
minLength: 2
});
});
</script>
</head>
<body>
<form>
<table>
<tr><td>Name:</td><td><input type="text"
id="name" name="name" /></td></tr>
</table><br />
<input type="submit" value="OK"/>
</form>
</body>
</html>