下面是fiddle (底部的指令):
http://jsfiddle.net/swfjT/249/
我该如何让点击下拉菜单中的自动补全项直接指向一个链接,比如/#/name/:name
,而不是登录点击输入/回车?找不到任何能做到这一点的东西。
基本上,单击Oscar即可重定向。
发布于 2013-06-26 00:46:28
当"...从菜单中选择了一项“时,jQuery UI的自动完成插件会触发一个select
回调。
此回调函数接收event
和ui
参数。ui
参数包含对所选项目的引用,这使您可以轻松构建要查找的重定向:
angular.module('MyModule', ['ui.keypress'])
.directive('autoComplete', function($timeout, $location) {
return function(scope, iElement, iAttrs) {
iElement.autocomplete({
source: scope[iAttrs.uiItems],
select: function(event, ui) {
var path = '/#/name/' + ui.item.value;
console.log('redirecting to', path);
$location.url(path);
return false;
}
});
};
});
https://stackoverflow.com/questions/17302502
复制相似问题