您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 榆林分类信息网,免费分类信息发布

PlayFramework完整实现一个APP(十)

2025/4/2 4:05:07发布21次查看
1.定制comment列表
新增加comment list页面,执行命令行
> play crud:ov --template comments/list
会生成/app/views/comments/list.html 
生成的文件中 #{crud.table /} 是表格的内容,可以替换为一下内容,显示更多的列
#{crud.table fields:['content', 'post', 'author'] /}
如果要对某一列的内容进行处理
#{crud.table fields:['content', 'post', 'author']}
#{crud.custom 'content'}
 <a href="@{comments.show(object.id)}">
  ${object.content.length() > 50 ? object.content[0..50] + '…' : object.content}
 </a>
#{/crud.custom}
#{/crud.table}
2.定制post表单
>play crud:ov --template posts/show
修改#{crud.form /} 
#{crud.form}
   #{crud.custom 'tags'}
       <label for="tags">
           &{'tags'}
       </label>
       <style type="text/css">
       .tags-list .tag {
           cursor: pointer;
           padding: 1px 4px;
       }
       .tags-list .selected {
           background: #222;
           color: #fff;
       }
   </style>
   <script type="text/javascript">
       var toggle = function(tagel) {
           var input = document.getelementbyid('h'+tagel.id);
           if(tagel.classname.indexof('selected') > -1) {
               tagel.classname = 'tag';
               input.value = '';
           } else {
               tagel.classname = 'tag selected';
               input.value = tagel.id;
           }
       }
   </script>
   <div class="tags-list">
       #{list items:models.tag.findall(), as:'tag'}
          <span id="${tag.id}" onclick="toggle(this)"
class="tag ${object.tags.contains(tag) ? 'selected' : ''}">
              ${tag}
          </span>
          <input id="h${tag.id}" type="hidden" name="${fieldname}"
value="${object.tags.contains(tag) ? tag.id : ''}" />
       #{/list}
   </div>
   #{/crud.custom}
#{/crud.form}
以上就是playframework完整实现一个app(十)的内容。
榆林分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录