【问题标题】:How to set attribute values for Backbone views?如何为 Backbone 视图设置属性值?
【发布时间】:2015-01-24 06:30:34
【问题描述】:

我正在构建一个 Marionette 项目视图,它是一个 a 元素。

我想知道如何使用 Mationette 获得有效的 a 元素,因为我的代码没有设置 href 属性:

class CategoryFilters.ItemView extends App.Views.ItemView
    tagName: "a"
    className: "btn btn-primary"
    template: "topics/categoryFilter/filter-item"
    triggers:
      "click": "filter:clicked"

给出结果:

<a class="btn btn-primary">company</a>

看起来不错,但是这个标签没有href 属性。

如何以干净的方式在此视图上设置href="#"

【问题讨论】:

    标签: backbone.js coffeescript marionette


    【解决方案1】:

    您可以使用attributes 属性,例如...

    attributes: { href: '#' }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-08
      • 1970-01-01
      • 2012-04-13
      • 1970-01-01
      • 1970-01-01
      • 2015-02-09
      • 2012-07-11
      相关资源
      最近更新 更多