Skip to content

Commit

Permalink
input不支持IE添加propertychange事件支持IE
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 8, 2015
1 parent e571690 commit 1dfdf3a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
14 changes: 10 additions & 4 deletions build/MDEditor.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
};
Expand Down
17 changes: 12 additions & 5 deletions lib/MDEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,10 @@

css(self.preview,{'height':self.textarea.offsetHeight + "px"});

//实时监听输入框值变化 HTML5事件
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{
Expand All @@ -184,8 +183,16 @@
});
}
css(self.preview,{'height':self.textarea.offsetHeight + "px"});
self.opts.value = this.value
self.opts.value = obj.value
self.callback(event,self.opts)
}

//实时监听输入框值变化 HTML5事件
addEvent(self.textarea,'input', function(event) {
valueChange(this,event)
});
addEvent(self.textarea,'propertychange', function(event) {
valueChange(this,event)
});
return this;
}
Expand Down

0 comments on commit 1dfdf3a

Please sign in to comment.