Tyepahead search results misplaced with validation

只愿长相守 提交于 2019-12-13 21:07:51

问题


I am using a validation plug-in based on jQuery validation in my AngularJS app (which is built on top of a jQuery library).

When I use ui bootstrap Typeahead with validation the search results are misplaced.

Plunkr:

http://plnkr.co/edit/ZYP58GxITghkTqE7PNHy

HTML (help.html)

<div class="form-group">
        <label for="category">Category "{{formData.category}}"</label>
          <input class="form-control" type="text" name="category" id="category" placeholder="Search..." ng-model="formData.category" typeahead="obj.name for obj in getCdOnCat($viewValue)" typeahead-editable="false" typeahead-loading="loadingLocations" required>
    </div>

JS (script.js) - HelpController

//Typeahead: Category Search
    $scope.getCdOnCat = function (searchVal) {
        return dataFactory.getCdOnCategory(searchVal).then(function (response) {
            return response.data.categories;
        }, function (error) {
            console.log('Error: dataFactory.getCdOnCategory');
        });
    };

    $scope.$watch('formData.category', function (value) {
        if (value === "No matching categories") {
            $scope.formData.category = "";
        }
    });

来源:https://stackoverflow.com/questions/26816277/tyepahead-search-results-misplaced-with-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!