小编nob*_*ody的帖子

Backbone.js:初始化中的_.bindAll() - 为什么要使用它?

我一直在看一些基于backbone.js的应用程序的例子.我注意到在某些(例如下面这个例子)中使用了下划线函数_.bindAll():

 initialize: function (args) {
        _.bindAll(this, 'changeTitle');
        this.model.bind('change:title', this.changeTitle);
    },
Run Code Online (Sandbox Code Playgroud)

而在其他情况下(例如下面的todo应用程序)不要:

initialize: function() {
  this.model.bind('change', this.render, this);
  this.model.bind('destroy', this.remove, this);
},
Run Code Online (Sandbox Code Playgroud)

_.bindAll()在这种情况下,目的是什么,是否有必要?

backbone.js

25
推荐指数
1
解决办法
2万
查看次数

bootstrap-sass:未定义的变量:"$ baseLineHeight"

我使用bootstrap-sass将bootstrap集成到我的应用程序中.该应用程序在我的本地计算机上工作正常,但当我通过capistrano部署时,我收到此错误:

Undefined variable: "$baseLineHeight".
(in /var/www/CollegeSportsBlueBook/shared/bundle/ruby/1.9.1/gems/bootstrap-sass-2.0.1/vendor/assets/stylesheets/bootstrap/_accordion.scss)
Run Code Online (Sandbox Code Playgroud)

当capistrano试图跑 assets:precompile

我认为这个变量抛出错误,因为它是第一个尝试预编译的scss文件中的第一个变量.

有些事情没有正确加载.任何想法可能是什么?

编辑

完整跟踪https://gist.github.com/2233071

编辑2

将application.rb和production.rb添加到gist

ruby-on-rails twitter-bootstrap bootstrap-sass

17
推荐指数
1
解决办法
1万
查看次数

如何在rails app中使用twitter bootstrap和bootstrap-sass?

我对此很新,但我无法弄清楚问题.

在twitter bootstrap中我会使用:

<div class="row-fluid">
  <div class="span2">Column1</div>
  <div class="span6">Column2</div>
</div>
Run Code Online (Sandbox Code Playgroud)

一切正常.但我不想直接将spanX和spanY写入我的html文件,而是想提供有意义的类名,例如:

<div class="user-container">
  <div class="user-filter">First Column</div>
  <div class="user-list">Second Column</div>
</div>
Run Code Online (Sandbox Code Playgroud)

鉴于事实,我正在使用https://github.com/thomas-mcdonald/bootstrap-sass,我该如何编写我的scss文件?我尝试过以下操作,但它不起作用(不显示两列):

@import "bootstrap";
@import "bootstrap-responsive";

.user-container {
    @extend .row-fluid;
}

.user-filter {
    @extend .span2;
}

.user-list {
    @extend .span10;
}
Run Code Online (Sandbox Code Playgroud)

如果我看一下生成的代码,在我看来一切都应该没问题:

/* line 164, ../../../../../.rvm/gems/ruby-1.9.3-p125/gems/bootstrap-sass-2.0.0/vendor/assets/stylesheets/bootstrap/_mixins.scss */
.span2, .user-filter {
  width: 140px;
}
Run Code Online (Sandbox Code Playgroud)

等等.

我究竟做错了什么?

更新:

好吧,只是为了清楚是什么问题 - 列被列为行(一个接一个),而不是真正的列(彼此相邻),例如:

with bootstrap:Column1 Column2
with my custom classes:
First Column
Second Column

我已经检查过Chrome中的元素布局,似乎bootstrap类有float属性,而我的 - 没有.看看css源我看到这样的类:

[class*="span"] {
  float: left;
  margin-left: 20px; …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails twitter-bootstrap bootstrap-sass

13
推荐指数
1
解决办法
9053
查看次数

将JSON解析为ListView友好输出

所以我有这个JSON,然后我的活动检索到一个字符串:

    {"popular":
        {"authors_last_month": [
         {
            "url":"http://activeden.net/user/OXYLUS",
            "item":"OXYLUS",
            "sales":"1148",
            "image":"http://s3.envato.com/files/15599.jpg"
         },
         {
            "url":"http://activeden.net/user/digitalscience",
            "item":"digitalscience",
            "sales":"681",
            "image":"http://s3.envato.com/files/232005.jpg"
         }
         {
            ...
         }
        ],
        "items_last_week": [
         {
            "cost":"4.00",
            "thumbnail":"http://s3.envato.com/files/227943.jpg",
            "url":"http://activeden.net/item/christmas-decoration-balls/75682",
            "sales":"43",
            "item":"Christmas Decoration Balls",
            "rating":"3",
            "id":"75682"
         },
         {
            "cost":"30.00",
            "thumbnail":"http://s3.envato.com/files/226221.jpg",
            "url":"http://activeden.net/item/xml-flip-book-as3/63869",
            "sales":"27",
            "item":"XML Flip Book / AS3",
            "rating":"5",
            "id":"63869"
         },
         {
            ...
         }],
        "items_last_three_months": [
         {
            "cost":"5.00",
            "thumbnail":"http://s3.envato.com/files/195638.jpg",
            "url":"http://activeden.net/item/image-logo-shiner-effect/55085",
            "sales":"641",
            "item":"image logo shiner effect",
            "rating":"5",
            "id":"55085"
         },
         {
            "cost":"15.00",
            "thumbnail":"http://s3.envato.com/files/180749.png",
            "url":"http://activeden.net/item/banner-rotator-with-auto-delay-time/22243",
            "sales":"533",
            "item":"BANNER ROTATOR with Auto Delay Time",
            "rating":"5",
            "id":"22243"},
         {
            ...
         }]
    } …
Run Code Online (Sandbox Code Playgroud)

android json

6
推荐指数
1
解决办法
5553
查看次数