Я добавил SummerNote Editor на свой веб-сайт, и я пытаюсь сделать упоминание. У меня проблема:
Работает нормально, если оставить так: `
jQuery(document).ready(function(e) {
$("#content").summernote({
dialogsInBody: true,
height: 150,
toolbar: [
['font', ['bold', 'italic', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture', 'video', 'hr']]
],
hint: {
mentions: [{"userid":"25","name":"Checkbnotif","dir":"201910","avatar":"","slug":"checkbnotif"}],
match: /\B@(\w*)$/,
search: function (keyword, callback) {
callback($.grep(this.mentions, function (item) {
return item.slug.indexOf(keyword) == 0;
}));
},
template: function (item) {
return '<img src="'+ baseURL + 'assets/userstore/'+ item.dir +'/'+ item.avatar + '" width="20" />' + item.name + '';
},
content: function (item) {
return $('<span><b><span class="href" data-id="'+item.usserid+'">@' + item.name + '</span> </b></span>')[0];
}
}
});
});
`
Но когда я использую phpfile для упоминания, он не работает: `
jQuery(document).ready(function(e) {
$("#content").summernote({
dialogsInBody: true,
height: 150,
toolbar: [
['font', ['bold', 'italic', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture', 'video', 'hr']]
],
hint: {
match: /\B@(\w*)$/,
mentions: function(keyword, callback) {
$.ajax({
url: baseURL + "thanh_vien/userjson/" + keyword,
type: 'get',
dataType: "json",
async: false
}).done(callback);
},
search: function (keyword, callback) {
callback($.grep(this.mentions, function (item) {
return item.slug.indexOf(keyword) == 0;
}));
},
template: function (item) {
return '<img src="'+ baseURL + 'assets/userstore/'+ item.dir +'/'+ item.avatar + '" width="20" />' + item.name + '';
},
content: function (item) {
return $('<span><b><span class="href" data-id="'+item.usserid+'">@' + item.name + '</span> </b></span>')[0];
}
}
});
});
`
Мой php файл json данные выглядят так:
[{"userid":"25","name":"Checkbnotif","dir":"201910","avatar":"","slug":"checkbnotif"}]
Пожалуйста, покажите мне как это работает ! Я новичок ie, и я пытаюсь что-то сделать! Извините, мой английский sh