Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
BOBGrile opened this issue Jul 8, 2016 · 1 comment

Comments

@BOBGrile
Copy link

BOBGrile commented Jul 8, 2016

阅读您的代码对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封装、设计模式方面的书籍。目前也正在学习您的云网易课程。

@wangfupeng1988
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants