如何从自动完成重定向到 (jquery)
How to redirect to from autocomplete (jquery)
我的products.js.coffee
$ ->
$('#titles').autocomplete(
source: gon.titles
minLength: 2).click ->
$(this).autocomplete 'search'
return
return
我的index.html.erb
...
<div class="ui-widget">
<input id="titles" />
</div>
...
在源代码中,我有所有产品的标题(我使用 gon gem)。我想从自动完成中选择产品并重定向到所选产品。
感谢您的指教!
我的解决方案products.js.coffee
doSearch = (term, location) ->
window.location.href = 'products?utf8=✓&search=' + term + '&commit=Search'
return
$(document).ready ->
$('#titles').autocomplete
minLength: 1
source: gon.titles
select: (event, ui) ->
doSearch ui.item.label, ui.item.city
return
return
我的products.js.coffee
$ ->
$('#titles').autocomplete(
source: gon.titles
minLength: 2).click ->
$(this).autocomplete 'search'
return
return
我的index.html.erb
...
<div class="ui-widget">
<input id="titles" />
</div>
...
在源代码中,我有所有产品的标题(我使用 gon gem)。我想从自动完成中选择产品并重定向到所选产品。
感谢您的指教!
我的解决方案products.js.coffee
doSearch = (term, location) ->
window.location.href = 'products?utf8=✓&search=' + term + '&commit=Search'
return
$(document).ready ->
$('#titles').autocomplete
minLength: 1
source: gon.titles
select: (event, ui) ->
doSearch ui.item.label, ui.item.city
return
return