Когда плагин находит имя, он обычно добавляет значок рядом с ним. При нажатии должно появиться всплывающее окно начальной загрузки с дополнительной информацией о человеке.
Когда я пытаюсь запустить свой код, я получаю эту ошибку:
VM887:1 Uncaught TypeError: $(...).popover не является функцией(…)
Вот мой код:
Код: Выделить всё
$('head').append('\
');
$(document).ready(function(){
var name = "Nicolas";
// console.log('Document is ready.. scanning for politicians...');
//var hashmap = db_reader.getHashMap();
var counter = {i: 0}; //Occurences. Singleton to be passed by reference and not by value.
$('p').each(function(index) {
addImage(this, counter);
});
$('li').each(function(index) {
addImage(this, counter)
});
$('head').append(
"$(function(){$('[data-toggle=\"popover\"]').popover();});\
"
);
});
function addImage(context, counter) {
var body = $(context).text();
var word;
var reg = /[A-Z]+[a-z]*/gm;
while(word = reg.exec(body)){
// console.log("while");
if(word == name){
// console.log(word);
var image = '[url=#]\
[img]https://s15.postimg.org/pei4ci3fv/fdp.png[/img]
\
[/url]';
// console.log("Replacing HTML");
$(context).html(body.replace(word, word + " " + image));
counter.i++;
}
}
}
С уважением,
Флориан >
Подробнее здесь: https://stackoverflow.com/questions/402 ... a-function
Мобильная версия