3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Backbone.js(Marionette.js) + stickit で自分自身の要素をバインディングしたい時

Posted at

stickitは、Backbone.jsで相互バインディングをしたい時に便利なライブラリですが、サンプルを見ると、bindings: に子要素のセレクタを指定する例ばかりで、自分自身をセレクタとして指定したい場合にどうしたらいいのか分からずハマりました。

結論としては、セレクタに ':el' と指定するだけです。
公式ドキュメント をよーく見たら書いてありました… orz

sample.js
var itemView = Marionette.ItemView.extend({
  tagName: 'textarea',
  id: 'test1',
  template: _.template("<%= text %>"),

  bindings: {
    ':el': 'text'
  },

  onRender: function() {
    this.stickit();
  }
});
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?