online html editor question

26 views
Skip to first unread message

刘久武

unread,
Mar 19, 2015, 10:53:19 AM3/19/15
to lif...@googlegroups.com
<div class="modal-body" data-lift="admin.ArticleSpt.create?eager_eval=true">
<div class="form-group">
       
<label class="control-label">文章内容</label> <input type="hidden" name="content" id="content" />
       
<script type="text/plain" id="editor" style="height: 240px;"></script>
   
</div>

   
<button type="submit" class="btn btn-primary" id="id_btn_save">
       
<i class="fa fa-check"></i> 确定发布
   
</button>
   
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
   
<lift:tail>
       
<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
       
<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.js"></script>
       
<script type="text/javascript" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
       
<script type="text/javascript">
           
// <![CDATA[
            $
(function() {
               
var ue = UE.getEditor('editor');
                ue
.ready(function(editor) {
                    ue
.setContent($("#content").val());
               
});

             
  $("#id_btn_save").click(function() {
                    $
("#content").val(ue.getContent());
               
})

           
})
           
// ]]>
       
</script>
   
</lift:tail>
</div>

===================================================
 def create = {
    var title, content, summary = ""
    var articleType = ArticleType.Notice

    def doSubmit(): JsCmd = {
      if (title.length() < 5 || title.length() > 50) {
        return S.error("文章标题长度为5-50个字符")
      }

      if (summary.length() < 5 || summary.length() > 500) {
        return S.error("文章摘要长度为5-500个字符")
      }

      val len = content.length()
      if (len < 10 || len > 400) {
        return S.error("文章内容长度为10-400个字符")
      }

      Article.create.title(title).articleType(articleType).content(content).save()
      Reload
    }

    "#title" #> SHtml.text(title, title = _) &
      "#articleType" #> SHtml.selectObj[ArticleType.Value](ArticleType.values.toList.map(v => (v, v.toString)), Full(ArticleType.Notice), x => articleType = x) &
      "#summary" #> SHtml.textarea(summary, summary = _) &
      "#content" #> SHtml.hidden(content = _, content) &
      ":submit" #> SHtml.ajaxOnSubmit(doSubmit)
  }






The code work liftweb 2.6,but liftweb 3.0-M2 not work. why?

Thanks!

Torsten Uhlmann

unread,
Mar 19, 2015, 11:49:43 AM3/19/15
to lif...@googlegroups.com
Can you check the developer console in your browser for errors? Is jQuery properly loaded?

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
AGYNAMIX(R). Passionate Software.
Inh. Torsten Uhlmann | Buchenweg 5 | 09380 Thalheim
Phone:     +49 3721 273445
Fax:         +49 3721 273446
Mobile:     +49 151 12412427
Web:        http://www.agynamix.de

刘久武

unread,
Mar 19, 2015, 10:35:09 PM3/19/15
to lif...@googlegroups.com
thanks, jquery loaded in base template,js is correct.

form ajax submit berfore, can set editor data to hidden element(content)?  use liftweb 2.6  is work.

在 2015年3月19日星期四 UTC+8下午11:49:43,Torsten Uhlmann写道:

Antonio Salazar Cardozo

unread,
Mar 21, 2015, 6:19:16 PM3/21/15
to lif...@googlegroups.com
The best thing here will be to break this down into an example project (see https://www.assembla.com/wiki/show/liftweb/Posting_example_code)
so that we can reproduce it locally and try and figure out what's up.

Also worth checking is if there's a difference in what you see in the DOM on the page between the
two versions.
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages