首页 \ 问答 \ 又一个jQuery自动完成线程(Yet another jQuery autocomplete thread)

又一个jQuery自动完成线程(Yet another jQuery autocomplete thread)

我试图弄清楚我的代码(Laravel5项目)有什么问题。

到目前为止,我有:master.blade.php

<!-- jQuery Version 1.11.0 and jQuery UI-->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="{{asset("patho/to/jquery/jquery-1.11.0.js")}}"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

主视图在任何视图中预加载,它用作页眉和页脚包装器。 请注意,我混淆了jQuery脚本的本地路径,它是真实的,它已加载并且可以正常工作。

包含在我的一个CRUD视图中:create.blade.php

{!! Form::select('league_id',[], Request::old('league_id'), array('class' => 'form-control', 'id' => 'league_name')) !!}
<script src="{{ asset('js/tips.js') }}">

在我的tips.js文件中:

$(document).ready(function() {
    var dataSource = ['test1', 'test2'];
    $('#league_name').autocomplete(
        {
            source: dataSource
        }
    );
});

我也尝试过:

var dataSource = [{value: 'test1', name: 'test1'}]

但它仍然根本不起作用,也没有显示控制台错误。

有什么线索吗?

编辑:跟随michaelbahr的建议:

自动完成小部件根本不执行,我得到的结果选择下拉列表只是一个空的。 小部件中没有项目,也没有搜索框。 一个简单的空选:

<select class="form-control ui-autocomplete-input" id="league_name" name="league_id" autocomplete="off"></select>

I am trying to figure out what's wrong with my code (Laravel5 project).

So far I have: master.blade.php

<!-- jQuery Version 1.11.0 and jQuery UI-->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="{{asset("patho/to/jquery/jquery-1.11.0.js")}}"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

the master view is preloaded in any view, it serves as a header and footer wrapper. Note that I obfuscated the local path to jQuery script, it's real and it's loaded and it works.

Included in one of my CRUD views: create.blade.php

{!! Form::select('league_id',[], Request::old('league_id'), array('class' => 'form-control', 'id' => 'league_name')) !!}
<script src="{{ asset('js/tips.js') }}">

And in my tips.js file:

$(document).ready(function() {
    var dataSource = ['test1', 'test2'];
    $('#league_name').autocomplete(
        {
            source: dataSource
        }
    );
});

I also tried with:

var dataSource = [{value: 'test1', name: 'test1'}]

Yet it still does not work at all, no console errors displayed either.

Any clues?

Edit: following michaelbahr's suggestion:

the autocomplete widget doesn't execute at all, the resulting select dropdown I get is just an empty one. No items, no search box from the widget. A plain, empty select:

<select class="form-control ui-autocomplete-input" id="league_name" name="league_id" autocomplete="off"></select>

原文:https://stackoverflow.com/questions/32006298
更新时间:2023-11-21 14:11

最满意答案

使用这两个通用规则而不是上述类型的规则:

RewriteCond %{DOCUMENT_ROOT}/aponit/dev/$1/$2\.php -f
RewriteRule ^([\w-]+)/([\w-]+)/?$ $1/$2.php [L]

RewriteCond %{DOCUMENT_ROOT}/aponit/dev/$1/$2\.php -f
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ $1/$2.php?q=$3 [L,QSA]

请注意,所有这些URL的GET参数的名称都是相同的。 在.php文件里,你可以使用$_GET['q']来读取它。


Use these two generic rules instead of above type of rules:

RewriteCond %{DOCUMENT_ROOT}/aponit/dev/$1/$2\.php -f
RewriteRule ^([\w-]+)/([\w-]+)/?$ $1/$2.php [L]

RewriteCond %{DOCUMENT_ROOT}/aponit/dev/$1/$2\.php -f
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ $1/$2.php?q=$3 [L,QSA]

Please note that name of the GET parameter will be same q for all such URLs. Inside .php file you can use $_GET['q'] to read it.

相关问答

更多
  • 将最后一次重写更改为: RewriteCond %{HTTP_HOST} ^blog\.example\.com$ [NC] RewriteCond %{REQUEST_URI} !feed/?$ RewriteRule ^(.*)$ https://www.example.com/articles/$1 [R=301,L] Change the last rewriterule to this: RewriteCond %{HTTP_HOST} ^blog\.example\.com$ [NC] Rew ...
  • 好吧,您已经知道如何判断用户是否在子域上,因为您已经为控制器执行了操作: RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC] RewriteRule ^$ pages/public_subdomain_blog.php [L,QSA] 尽管可能会或者可能无法简化整个规则集,但最简单的方法是以相同的方式调整规则。 由于子域规则较少,我们可以移动主站点规则以上的规则并使用您拥有的条件有条件地应用重写: ## THESE RULES SHOULD ONLY ...
  • Redirect和RedirectMatch是mod_alias的一部分,而重写规则是mod_rewrite的一部分。 您遇到的问题是当您混合使用两个模块时, 两个模块都会影响同一个请求,因此当您只需要一个模块时会发生两件事。 在这种情况下,您需要坚持使用mod_rewrite并使用它: RewriteEngine On RewriteRule ^about_us /about-us [L,R=301] RewriteCond %{REQUEST_URI} !^(index\.php|/images|/ ...
  • 由于您的模式完全相同,因此第一个和第二个规则之间没有区别,因此第一个规则始终匹配, klant ,您将始终获得klant查询字符串。 您可以对页面名称进行硬编码,如果这是唯一不同的内容: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^werknemers/(.*)$ index.php?page=werknemers&klant=$1 [L] RewriteCond %{REQUES ...
  • 尝试更改规则并为这两个规则添加条件。 看看这是否有帮助。 RewriteEngine On RewriteRule ^home/?$ index.php [NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ serv ...
  • 试试这个让我知道。 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^profile/([^/])/? profile.php?username=$1 [L,NC] RewriteRule ^login/submit$ login.php?action=submit [L,NC] # /login/ will go to ...
  • RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] ^www\.example\.com$锚点^$表示这是HTTP_HOST的完整字符串,之前或之后都没有。 因此,如果随请求一起传递的域名与www.example.com 完全匹配,则整个URI (.*)将重定向到example.com ,从而剥离www. 从前面。 RewriteCond %{REQUEST ...
  • 使用这两个通用规则而不是上述类型的规则: RewriteCond %{DOCUMENT_ROOT}/aponit/dev/$1/$2\.php -f RewriteRule ^([\w-]+)/([\w-]+)/?$ $1/$2.php [L] RewriteCond %{DOCUMENT_ROOT}/aponit/dev/$1/$2\.php -f RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ $1/$2.php?q=$3 [L,QSA] 请注意,所有这些URL ...
  • 您可以使用: RewriteRule ^award/(?:add|(\d+))/?$ admin.php?io=award&award=$1 [L] award/add一个空参数award 。 要么: RewriteRule ^award/(add|\d+)/?$ admin.php?io=award&award=$1 [L] award=add award/add 。 You can use: RewriteRule ^award/(?:add|(\d+))/?$ admin.php?io=award ...
  • 这两条规则相互冲突。 一个人将test.php写入测试,另一个人将测试写入test.php,这可能会让你陷入无限循环,无论是在重写引擎内还是在浏览器和服务器之间,这取决于你如何实现重写。 为了解决这个问题,我使用了一个条件来检查请求的URI而不是当前重写的URI。 试试这个: RewriteRule ^test/$ test.php [NC] RewriteCond %{THE_REQUEST} ^[A-Z]+\ (/[^\ ]*)\.php[?\ ] RewriteRule ^test\.php(.*) ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)