【问题标题】:backbone.js escaping html主干.js 转义 html
【发布时间】:2013-09-08 04:14:54
【问题描述】:

我使用backbone.js从我的数据库中提取html以显示在我的页面上

数据是这样存储的

测试

测试1

测试2

使用 underscore.js 时在我的页面中

pp

    </div>            </div>      </script>

  <!-- sample template for pagination UI -->      <script

type="text/html" id="tmpServerPagination">

              <% if (currentPage < totalPages) { %>
                  <a href="#" class="btn long servernext">Show More</a>
              <% } %>

        </div>
    </script>

它呈现

测试

测试 1

测试 2

我希望它在哪里读取标签并将格式应用于页面

测试 测试 1 测试 2

这是我的看法

(函数(视图){

views.ResultView = Backbone.View.extend({ 标记名称:'李', 模板:_.template($('#resultItemTemplate').html()), 初始化:function() { this.model.bind('change', this.render, this); this.model.bind('destroy', this.remove, this); },

  render : function () {
      this.$el.html(this.template(this.model.toJSON()));          return this;
  }   });

})(app.views);

【问题讨论】:

  • 想从字符串中删除html标签?

标签: javascript jquery html backbone.js


【解决方案1】:

如果您只是想内联显示段落,那么您可以使用:

p { display: inline-block; }

你可能想要命名这个(例如.pagination p),这样它就不会影响页面上的所有段落。

【讨论】:

    猜你喜欢
    • 2012-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-31
    • 1970-01-01
    相关资源
    最近更新 更多