2
2

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.ViewのclassNameにクラスを複数指定できる

Last updated at Posted at 2013-10-08

追記

内部的には_.resultメソッド使ってるから、文字列を返すメソッドでもおk

http://backbonejs.org/backbone.js

スクリーンショット 2013-10-13 18.16.43.png


var HogeView = Backbone.View.extend({
  className: 'aaa bbb ccc',
  tagName: 'p'
});

$(function() {  
  var hogeView = new HogeView();
  var html = hogeView.render().el;
  $('#multiple-class-demo').append(html);
});
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="http://documentcloud.github.io/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.io/backbone/backbone-min.js"></script>
<meta charset=utf-8 />
<title>demo</title>
</head>
<body>
  <div id="multiple-class-demo"></div>
</body>
</html>
.aaa {
  outline: 5px solid #00f;
  width: 100px;
}
.bbb {
  border: 5px solid #0f0;
  height: 100px;
}
.ccc {
  background: #f00; 
}

スクリーンショット 2013-10-08 17.01.26.png

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?