我的 Rails 应用程序有问题 - 我有两个脚本使彼此无法正常工作。首先,algolia 搜索引擎脚本(运行良好)
在 app/assets/javascript/algolia.js 中:
$(document).ready(function() {
// Replace the following values by your ApplicationID and ApiKey.
var algolia = new AlgoliaSearch('MYAPPID', 'MYAPPPWD');
// replace YourIndexName by the name of the index you want to query.
var index = algolia.initIndex('Pin');
// Mustache templating by Hogan.js (http://mustache.github.io/)
var template = Hogan.compile('<div class="hit">' +
'<a href="http://0.0.0.0:3000/pins/{{{slug}}}">'
+
'<div class="name">' +
'{{{ _highlightResult.description.value }}} ' +
'</div>' +
'</a>' +
'</div>');
// typeahead.js initialization
$('#user-search').typeahead(null, {
source: index.ttAdapter({ hitsPerPage: 5 }),
displayKey: 'description',
templates: {
suggestion: function(hit) {
// select matching attributes only
hit.matchingAttributes = [];
for (var attribute in hit._highlightResult) {
if (attribute === 'name' || attribute == 'company') {
// already handled by the template
continue;
}
// all others attributes that are matching should be added in the matchingAttributes array
// so we can display them in the dropdown menu. Non-matching attributes are skipped.
if (hit._highlightResult[attribute].matchLevel !== 'none') {
hit.matchingAttributes.push({ attribute: attribute, value: hit._highlightResult[attribute].value });
}
}
// render the hit using Hogan.js
return template.render(hit);
}
}
});
});
以及使用magnific-popup-gem加载弹出窗口的脚本
$(function() {
$('.please-login').magnificPopup({
type: 'inline',
preloader: false,
focus: '#username',
modal: true
});
$(document).on('click', '.please-login-dismiss', function (e) {
e.preventDefault();
$.magnificPopup.close();
});
});
看起来这些线条使宏伟的弹出窗口不起作用。
<script src="//cdn.jsdelivr.net/jquery/1.11.1/jquery.min.js"></script>
<!-- Typahead.js is used to display the auto-completion menu -->
<script src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.10.4/typeahead.bundle.min.js"></script>
<!-- Hogan.js is used to render the hits using Mustache.js templating -->
<script src="//cdn.jsdelivr.net/hogan.js/3.0.0/hogan.common.js"></script>
<!-- Algolia -->
<script src="//cdn.jsdelivr.net/algoliasearch/latest/algoliasearch.min.js"></script>
有什么想法可以解决这个问题吗?