微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我们可以在ASP.NET MVC的Froala编辑器中绑定数据集的Custom Dropdown值吗?

如何解决我们可以在ASP.NET MVC的Froala编辑器中绑定数据集的Custom Dropdown值吗?

下面是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 举报,一经查实,本站将立刻删除。