【问题标题】:Kendo UI Editor - open event剑道 UI 编辑器 - 打开事件
【发布时间】:2013-08-31 15:33:58
【问题描述】:

使用 Kendo UI 编辑器,用户可以单击“插入图像”按钮,然后会弹出图像浏览器。

我希望在用户单击编辑器外部的 div 时打开图像浏览器。 我怎样才能做到这一点?有可能吗?

我尝试搜索年龄,但似乎找不到任何答案。

【问题讨论】:

    标签: kendo-ui


    【解决方案1】:

    我忘了回来更新这篇文章,但最后,我使用了剑道编辑器并隐藏了所有内容。这是我所做的,希望有一天能对其他人有所帮助:

    .k-editable-area
    {
        display: none;
    }
    
    .k-editor
    {
        width: 4% !important;
        height: 28px !important;
        border: none !important;
        background-image: none;
        display: none;
        margin-left: 10px;
    }
    
    .k-window
    {
        display: none;
    }
    

    Javascript:

    $(document).ready(function () {
    
       $("#imgBrowser").kendoEditor({
           tools: [
               "insertImage"
           ],
           imageBrowser: {
               messages: {
                   dropFilesHere: "Drop files here"
               },
               transport: {
                   read: "/ImageBrowser/Read",
                   destroy: {
                       url: "/ImageBrowser/Destroy",
                       type: "POST"
                   },
                   create: {
                       url: "/ImageBrowser/Create",
                       type: "POST"
                   },
                   thumbnailUrl: "/ImageBrowser/Thumbnail",
                   uploadUrl: "/ImageBrowser/Upload",
                   imageUrl: "/ImageBrowser/Image?path={0}"
               },
               change: function () {
                   //this.value(); //Selected image URL
               },
               select: function () {
               }
           }, execute: function (e) {           
           },
           change: function () {
           },
           select: function () {
               //this.value(); //Selected image URL but each selection is appended... ie:             
               <img /> <img /> <img /> ... you need to replace all except the last one.
    
               SetSelectedImage(this.value());
    
           }
       });
    

    });

    然后我添加了一个链接,点击后会触发图像浏览器:

     <a id="imgBrowser"></a><a id="addImage" style="display: inline; cursor: pointer;    
     float: left; font-weight: bold">+ Add image</a>
    

    最后,我添加了 javascript 来进行触发:

     $("#addImage").click(function () {
       $(".k-tool-icon").trigger('click');
     });
    

    【讨论】:

      【解决方案2】:

      看看这个。在文本框的焦点上,调用下面的 jQuery 脚本。

      $('#editor').parent().parent().parent().parent().parent().parent().find('.k-insertImage').click();
      

      您可以查看此链接:kendo editor。 只需从浏览器控制台调用此脚本即可。

      【讨论】:

      • 谢谢,但最后我发现我可以使用这个:$(".k-tool-icon").trigger('click');
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-08
      • 1970-01-01
      • 2016-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多