Ruby on rails 主干找不到由模板创建的动态div 提取集合(确定) 索引渲染视图(确定)

Ruby on rails 主干找不到由模板创建的动态div 提取集合(确定) 索引渲染视图(确定),ruby-on-rails,backbone.js,coffeescript,Ruby On Rails,Backbone.js,Coffeescript,集合中单个项目的渲染视图(不确定) 类MyApp.Routers.ProjectsRouter扩展主干路由器 初始化:-> @projects=新建MyApp.Collections.ProjectsCollection() 路线: “项目”:“项目” 项目:-> @projects.fetch().done=> @视图=新建MyApp.Views.Projects.IndexView(集合:@Projects) $(“#项目”).html(@view.render().el) 类MyApp.V

集合中单个项目的渲染视图(不确定)

类MyApp.Routers.ProjectsRouter扩展主干路由器
初始化:->
@projects=新建MyApp.Collections.ProjectsCollection()
路线:
“项目”:“项目”
项目:->
@projects.fetch().done=>
@视图=新建MyApp.Views.Projects.IndexView(集合:@Projects)
$(“#项目”).html(@view.render().el)
类MyApp.Views.Projects.IndexView扩展了主干.View
模板:JST[“主干/模板/项目/索引”]
addAll:=>
@集合。每个(@addOne)
addOne:(项目)=>
视图=新建MyApp.Views.Projects.ProjectView({model:project})
**$(“.row fluid”).append(view.render().el)**
渲染:=>
@$el.html(@template(“”))
@addAll()
这
类MyApp.Views.Projects.ProjectView扩展了主干.View
模板:JST[“主干/模板/项目/项目”]
渲染:->
@$el.append(@template())
这
“.row fluid”未建立,我已使用firebug对其进行了调试。谁来帮帮我,我从过去的5到6个小时一直在磕头

谢谢

试试这个:

class MyApp.Routers.ProjectsRouter extends Backbone.Router
  projects: ->
    @projects.fetch().done =>
      @view = new MyApp.Views.Projects.IndexView(collection: @projects)
      $("#projects").html(@view.render().el)
      @view.addAll()

class MyApp.Views.Projects.IndexView extends Backbone.View
  render: =>
    @$el.html(@template('<div class="row-fluid"></div>'))
    this
类MyApp.Routers.ProjectsRouter扩展主干路由器
项目:->
@projects.fetch().done=>
@视图=新建MyApp.Views.Projects.IndexView(集合:@Projects)
$(“#项目”).html(@view.render().el)
@view.addAll()
类MyApp.Views.Projects.IndexView扩展了主干.View
渲染:=>
@$el.html(@template(“”))
这

愚蠢的问题,但是在模板中找到了
。行流体
?想展示一下模板代码吗?你能准备一些简单的JSFIDLE吗$(“.row fluid”)是全局选择器,因此您的DOM树中没有此类元素。在集合->
@view=new MyApp.Views.Projects.IndexView({collection:@Projects})
@msvalkon添加了模板代码@$el.html(@template('')
class MyApp.Routers.ProjectsRouter extends Backbone.Router
  projects: ->
    @projects.fetch().done =>
      @view = new MyApp.Views.Projects.IndexView(collection: @projects)
      $("#projects").html(@view.render().el)
      @view.addAll()

class MyApp.Views.Projects.IndexView extends Backbone.View
  render: =>
    @$el.html(@template('<div class="row-fluid"></div>'))
    this