使用 MOLECULE 迅速包装百度 UEditor

阅读: 评论:0

使用 MOLECULE 迅速包装百度 UEditor

使用 MOLECULE 迅速包装百度 UEditor

UEditor:

UEditor - 首页
/

我们在对话框上放了几个 UEditor,发现弹出对话框时可能UEditor没有初始化不能将数据设置上去,于是加了一个 setTimeout 反复重试,后来发现关闭对话框后再打开还是不能正确的设置上去,遂有如下代码:

1 2 3 4 5 6 7 8 9 10 11 ( function  setTitle(){      var  edt = UE.getEditor( "title" );      if (edt ==  null  || $(edt.body).is( ':visible' ) ==  false ){          setTimeout(setTitle, 10);          return ;      }      ady( function (){          this .setContent(tr.data( "title" ));          this .removeListener( 'ready' , arguments.callee)      }); })();

之后,可以将该玩意儿封装为一个 MOLECULE:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 < div  molecule-def="UEditor">      < script >              // MOLECULE_DEF              function UEditor(){                  // 创建                  var me = this;                  function updateContent(){                      var edt = UE.getEditor(me.el);                      if(edt == null || $(edt.body).is(':visible') == false){                          setTimeout(updateContent, 10);                          return;                      }                      ady(function(){                          this.setContent(me.value);                          veListener('ready', arguments.callee)                      });                  }                                    this.setValue = function(v){                      this.value = v;                      updateContent();                  }                  Value = function(){                      var edt = UE.getEditor(this.el);< br >                                        return edt ? Content() : this.value;                  }              }              // MOLECULE_DEF_END              ate(UEditor)      </ script > </ div >

该MOLECULE将值存放在 this.value 中,并包装了延迟设置逻辑,。

molecule 的两个函数命名为 getValue setValue,可以衔接 d2js 前端渲染器 molecule 和收集器 m。

本文发布于:2024-01-29 08:04:42,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170648668413864.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:MOLECULE   UEditor
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23