【发布时间】:2015-10-07 09:19:29
【问题描述】:
我正在将项目从 CQ 5.6.1 迁移到 AEM 6.1。
然后当我测试它时,发现我的代码中使用 typeahead.bundle.js 的部分不再工作了。当我返回在 CQ 5.6.1 中测试项目时,它运行良好。
试图隔离问题(获取代码的 sn-p 而不将其部署到 AEM 6.1)并且它工作正常。
我的初步发现是,仅 AEM 6.1 服务器可能会导致 typeahead.bundle.js 无法工作。
<html>
<head>
<script src="jquery-2.0.0.min.js"></script>
<script src="hogan-3.0.1.js"></script>
<script src="typeahead.bundle.js"></script>
</head>
<body>
<row>
<input id="country-search" type="text" class="typeahead form-control" placeholder="Country" title="Enter the terms you wish to search for" />
</row>
<script type="text/javascript">
$(document).ready(function() {
var countries = new Bloodhound({
name: 'countrysearch-countries',
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('englishName', 'localName'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 5,
prefetch: {
url: 'country.json',
}
});
var countrySuggestionTemplate = Hogan.compile('<p>{{localName}} ({{englishName}})</p>');
countries.initialize();
$("#country-search").typeahead(null, {
displayKey: 'localName',
source: countries.ttAdapter(),
templates: {
suggestion: function(country) {
return countrySuggestionTemplate.render(country);
}
}
}).on('typeahead:selected', function (e, datum) {
window.location = datum.url;
});
});
</script>
country.json的JSON字符串内容:
[{"url":"http://xxxx.com","localName":"افغانستان","englishName":"阿富汗"},{"url":"http://xxxx.com","localName":"Shqipëria" ,"englishName":"Albania"},{"url":"http://xxxx.com","localName":"الجزائر","englishName":"Algeria"}]
注意:请注意,上面的 HTML 脚本在未部署到 AEM 6.1 时可以正常工作。
希望大家能帮我重新评分。
谢谢
【问题讨论】:
标签: javascript jquery java-8 aem