wangEditor-mobile icon indicating copy to clipboard operation
wangEditor-mobile copied to clipboard

在外部调用editor.menus.img.bindEvent里的$inputFlie(FileInput)

Open BOBGrile opened this issue 8 years ago • 1 comments

阅读您的代码对JS的封装及函数的调用又深入一些了解,做了一些改写使之能支持外部调用到图片上传的功能,实现如下,但也遇到一些问题,觉得自己还需要学习; 首先是增加内容,具体如下:

  1. 给editor.menus.img对象增加“img_InputFileId”属性,存储InputFile的ID;
  2. editor.menus.img.bindEvent中,给$inputFlie.on('change', function (e) {}中的鼠标定位的标签对象,“$focusElem”增加一个判断;代码如下: if(typeof($focusElem) === "undefined"){ log("如是外部调用Img,则图片定位于文字最后"); $focusElem = $(".wangEditor-mobile-txt").children().last(); } 3.外部触发图片上传Input:$('#' + editor.menus.img.img_InputFileId).trigger('click');

其次介Old Plan: 给editor.menus.img对象增加“img_InputFile”属性,直接存储$('#' + inputFileId);对象;运行有问题,知道自己犯了一个概念性错误,但错在哪里,还请帮助指正一下。

最后,还请推荐一本关于JS封装、设计模式方面的书籍。目前也正在学习您的云网易课程。

BOBGrile avatar Jul 08 '16 03:07 BOBGrile

mobile 版本已经暂时不维护了,非常抱歉,原因参见 http://www.kancloud.cn/wangfupeng/wangeditor2/139064

js封装、设计模式的书籍:http://item.jd.com/11253887.html 《js设计模式》,另外还有汤姆大叔写的系列博客 http://www.cnblogs.com/TomXu/archive/2011/12/15/2288411.html

wangfupeng1988 avatar Jul 09 '16 03:07 wangfupeng1988