From 1dfdf3a4c8d7d9fe7a7960bac7bcb64929405145 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 8 Jul 2015 09:17:05 +0800 Subject: [PATCH] =?UTF-8?q?input=E4=B8=8D=E6=94=AF=E6=8C=81IE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0propertychange=E4=BA=8B=E4=BB=B6=E6=94=AF=E6=8C=81IE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/MDEditor.min.js | 14 ++++++++++---- lib/MDEditor.js | 17 ++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/build/MDEditor.min.js b/build/MDEditor.min.js index 95d4a3e..5ade662 100644 --- a/build/MDEditor.min.js +++ b/build/MDEditor.min.js @@ -913,10 +913,10 @@ css(self.preview, { height: self.textarea.offsetHeight + "px" }); - addEvent(self.textarea, "input", function(event) { - if (this.scrollHeight < self.opts.maxheight) { + valueChange = function(obj, event) { + if (obj.scrollHeight < self.opts.maxheight) { css(self.textarea, { - height: this.scrollHeight + "px", + height: obj.scrollHeight + "px", overflow: "hidden" }); } else { @@ -928,8 +928,14 @@ css(self.preview, { height: self.textarea.offsetHeight + "px" }); - self.opts.value = this.value; + self.opts.value = obj.value; self.callback(event, self.opts); + }; + addEvent(self.textarea, "input", function(event) { + valueChange(this, event); + }); + addEvent(self.textarea, "propertychange", function(event) { + valueChange(this, event); }); return this; }; diff --git a/lib/MDEditor.js b/lib/MDEditor.js index 886690c..9b05468 100644 --- a/lib/MDEditor.js +++ b/lib/MDEditor.js @@ -170,11 +170,10 @@ css(self.preview,{'height':self.textarea.offsetHeight + "px"}); - //实时监听输入框值变化 HTML5事件 - addEvent(self.textarea,'input', function(event) { - if(this.scrollHeight