相关疑难解决方法(0)

jQuery UI自动完成禁用选择和关闭事件

我使用jQuery UI的自动完成程序与创建它的方式略有不同.

基本上我想保留所有相同的功能,唯一的区别是当出现建议框时,我不会在用户进行选择时隐藏建议框,我也不希望该选择填充输入框.autocomplete附加到.

所以,我一直在阅读jQuery UI文档,看来有一种方法可以禁用Select:和Close:事件,但我发现他们解释它的方式非常混乱,因此,这就是为什么我我在这里寻求帮助.

我的jQuery

$( "#comment" ).autocomplete({
    source: "comments.php",
    minLength: 4,

    // Attempt to remove click/select functionality - may be a better way to do this        
    select: function( event, ui ) {
        return false;
    },
    // Attempt to add custom Class to the open Suggestion box - may be a better way
    open : function (event, ui) {
        $(this).addClass("suggestion-box");
    },
    // Attempt to cancel the Close event, so when someone makes a selection, the box does not close …
Run Code Online (Sandbox Code Playgroud)

jquery-ui autocomplete jquery-ui-autocomplete

16
推荐指数
2
解决办法
4万
查看次数

Angularjs jquery UI自动完成

我正在尝试在Angular指令中实现jquery的自动完成.我收到的源数据来自websocket响应.它不起作用,我认为响应延迟导致了这里的问题.

如果有人能够对下面的代码有所了解,我将不胜感激.使用某种请求/响应或承诺是否有任何优雅的技术来实现这一目标?

app.directive('autoComplete', function($rootScope, locationAutoCompleteService, $timeout, $http, programLocationModel ) {
    return {
        restrict: 'A',

        scope: {

            serviceType: '@serviceType'
        },

        link: function(scope, elem, attr, ctrl) {

            var autoItem = [];

            scope.change = function () {

                locationAutoCompleteService.unSubscribe();

                var service = locationAutoCompleteService.getServiceDefinition();

                service.filters.pattern = scope.inputVal;

                locationAutoCompleteService.subscribe();

            };

            scope.$on('myData', function(event, message){

                if ( message !== null && message.results !== null) {

                    autoItem = [];

                    for ( var i = 0; i < message.results.length; i++) {

                        autoItem.push({ label: message.results[i].name, id: message.results[i].id });
                    }

                }

            }); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery angularjs

10
推荐指数
1
解决办法
2万
查看次数

在angular.js工厂中使用$ http

在我的应用程序中,我使用angular.js和jquery ui自动完成.我遇到了与此处讨论的相同的问题. 对我来说,接受的答案很有用,而且直到今天我需要用$ http ajax调用替换静态数组值.我试图将$ http作为参数传递给父函数,但我得到"未知提供者:autoCompleteProvider < - autoComplete"

我的问题是,如何在不重写或更改当前解决方案的情况下使用$ http?

angularjs

5
推荐指数
1
解决办法
9608
查看次数