<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)
}
--
--
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.