0
我使用预输入自举3,其工作的罚款。我唯一的问题是,我不能输出get_stylesheet_directory_uri()在远程我的JSON国家数据的URL没有手动硬编码整个网址。 注意:我正在使用twitter的最新typeahead.js版本。 这里是我的代码:如何输出WordPress的样式表的URI预输入JS
var countries = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.name); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 10,
prefetch: {
url: ' http://Mydomainname.fr/wp-content/themes/inkness-child/lib/data/countries.json',
filter: function(list) {
return $.map(list, function(country) { return { name: country }; });
}
}
});
countries.initialize();
$('.example-countries .typeahead').typeahead(null, {
name: 'countries',
displayKey: 'name',
source: countries.ttAdapter()
});
我GOOGLE了一点,发现这个:
var templateUrl = '<?php get_stylesheet_directory_uri(); ?>';
,我试图implent像这样,但未能
url: +templateUrl+/lib/data/countries.json,
请帮助..谢谢你
感谢您的快速帮助。我已经试过,但不乏与你所说的试了一次。自动填充功能无法正常工作。我一定要确定您的建议是否回应了正确的路径和正确的路径。我试图硬编码的URL路径,并再次工作。在我看来,js does'nt interpt php标签。任何想法? – fritids