我是 Backbone 的新手,我正在尝试单击工具栏上的按钮(位于工具栏 div 上),该按钮称为“新建”。单击后,我想在 id="app-list" 的不同 div 上打开一个新面板。
但是当按下新按钮时,它总是覆盖“app-list”div
这是我的代码(我正在使用 Backbone 和 coffeescript):
class MyApp.Views.ToolbarAppView extends Backbone.View
el: "#toolbar-app"
events: "click #add_new": "newApp"
newApp: (e) ->
myapp = new MyApp.Models.App
@model = myapp
newPanel = new MyApp.Views.NewAppView({ el: @$el, model: @model, parent: @})
newParent.render()
class MyApp.Views.NewAppView extends Backbone.View
template: JST["myapp", "new_app_view"]
render: ->
fieldsPanel = new MyApp.Views.EditAppView({ el: @$el, model: @model, parent: @})
fieldsPanel.setElement('#app-list').render()
class MyApp.Views.EditAppView extends Backbone.View
template: JST["myapp", "edit_app_view"]
tagName: "tr"
className: "edit_data"
render: ->
@$el.html(@template({ el: @$el, model: @model, parent: @})