又一个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
最满意答案
使用这两个通用规则而不是上述类型的规则:
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.
相关问答
更多-
htaccess多次重写规则(htaccess multiple rewrite rules)[2022-04-07]
将最后一次重写更改为: 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 ... -
Htaccess子域规则(Htaccess subdomain rules)[2023-07-27]
好吧,您已经知道如何判断用户是否在子域上,因为您已经为控制器执行了操作: 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|/ ...
-
多个.htaccess规则?(Multiple .htaccess rules?)[2022-08-26]
由于您的模式完全相同,因此第一个和第二个规则之间没有区别,因此第一个规则始终匹配, klant ,您将始终获得klant查询字符串。 您可以对页面名称进行硬编码,如果这是唯一不同的内容: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^werknemers/(.*)$ index.php?page=werknemers&klant=$1 [L] RewriteCond %{REQUES ... -
Htaccess冲突规则(Htaccess conflict rules)[2023-12-09]
尝试更改规则并为这两个规则添加条件。 看看这是否有帮助。RewriteEngine On RewriteRule ^home/?$ index.php [NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ serv ... -
.htaccess重写规则(.htaccess rewrite rules)[2022-06-30]
试试这个让我知道。 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 ... -
解释htaccess规则?(Explain htaccess rules?)[2023-07-03]
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(.*) ...