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 初始化过程中触发了 onchange 事件 #26

Closed
tylerlong opened this issue Mar 3, 2015 · 5 comments
Closed

editor 初始化过程中触发了 onchange 事件 #26

tylerlong opened this issue Mar 3, 2015 · 5 comments

Comments

@tylerlong
Copy link
Contributor

https://pandao.github.io/editor.md/examples/onchange.html

页面打开,什么都没有做,没有做任何编辑, 控制台就打印了onchange信息。

把textarea内容清空,或者直接把textarea删除,再打开页面,问题依旧。

也就是说在没有内容,用户也没有做任何编辑的情况下,就触发了onchange。

v1.1.6发现的此问题,之前版本没有发现。

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

我把onchange回调处理合并到saveToTextareas()方法里了。比如在第一次加载时,通过动态设置markdown源文档的,可视作change了,但想想如果markdown是直接就设在textarea里,又不合理了。再考虑一下是否修改一下。

@tylerlong
Copy link
Contributor Author

还有一个特殊场景是: texarea内容为空,或者根本没有textarea。 这时候第一次加载不应该 动态设置markdown源文档, 也就不会触发change了。

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

还是改一下吧,初始化load后的change才算是。先标记一下。

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

@v1.1.7 fixed.

@pandao pandao closed this as completed Mar 3, 2015
@kz12
Copy link

kz12 commented Feb 5, 2018

//http://pandao.github.io/editor.md/examples/dynamic-create-editormd.html 在此基础上添加onchange函数

var testEditormd;

$(function() {                
    $("#create-btn").click(function(){                    
        $("#layout").append("<div id=\"test-editormd\"></div>");
        
        testEditormd = editormd("test-editormd", {
            width: "90%",
            height: 640,
            markdown : "### 动态创建 Editor.md\r\n\r\nDynamic create Editor.md",
            path : '/src/editormd/lib/',
            onchange: function() {
                console.log('editor onchange.....!!!!!')
            }
        });
    });  
    
    $("#remove-btn").click(function() {
        testEditormd.editor.remove();
    });
});

当创建,然后销毁编辑器,然后之后每次创建编辑器时,都会触发onchange事件。我用的editormd版本为1.5

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

3 participants