问题描述
下面是AJAX调用,用于从数据库中获取值, imgList 返回一个列表,我必须在“自定义”下拉列表中进行绑定。当前,imgList无法在 FroalaEditor.RegisterCommand ($ .each(imgList,function(key,value))
处检索值。如果有可能,soomone可以让我知道吗?
var imgList = [];
function GetAllImagesForFroala() {
$.ajax({
type: "GET",url: '/Test/GetAllImages',contentType: "application/json; charset=utf-8",dataType: "json",success: function (data) {
if (data != null) {
console.log(data);
$.each(data.images,function (key,value) {
imgList[value.IMAGE_URL] = value.IMAGE_NAME;
});
console.log(imgList);
}
return false;
},error: function (error) {
alert(error);
}
})
}
FroalaEditor.DefineIcon('my_dropdown',{ NAME: 'cog',SVG_KEY: 'cogs' });
FroalaEditor.RegisterCommand('my_dropdown',{
title: 'Advanced options',type: 'dropdown',focus: false,undo: false,refreshAfterCallback: true,//options: {},html: function () {
var html = '<ul class="fr-dropdown - list" role="presentation">';
$.each(imgList,value) {
html = html + '<li role="presentation"><a class="fr-command" tabindex="-1" role="option" data-cmd="campaigns" data-param1="' + 'test' + '" aria-selected="false">' + 'test2' + '</a></li>';
});
html = html + '</ul>';
return html;
},callback: function (cmd,val) {
var imgCode = '<img src="' + val + '"/>';
this.html.insert(imgCode);
this.undo.saveStep();
console.log(val);
},// Callback on refresh.
refresh: function ($btn) {
console.log('do refresh');
},// Callback on dropdown show.
refreshOnShow: function ($btn,$dropdown) {
console.log('do refresh when show');
}
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)