我正在尝试返回一个bucketlist对象,该bucketlist有关注者,bucketlist和它的属性正在通过,但是它的一系列关注者并不是。它返回" undefined"登录JS控制台时。
这是我记录它的地方:
var BucketlistShow = React.createClass({
mixins: [Backbone.React.Component.mixin],
render: function() {
var bucketlist = this.props.bucketlist;
var bucketlistName = bucketlist.name;
var followers = this.props.followers;
console.log(followers);
return(
以下是选项中设置的位置:
class IE.Views.BucketlistShowView extends Backbone.View
initialize: (options) ->
@bucketlist = options.bucketlist
@followers = options.followers
render: ->
React.render(BucketlistShowFactory({bucketlist: @bucketlist}), $("#bucketlist-
show-wrapper")[0]);
这是传递的地方:
#bucketlist-show-wrapper
:javascript
var bucketlist = #{@bucketlist.to_json}
var followers = #{@bucketlist.followers.to
$(document).ready(function(){
var view = new IE.Views.BucketlistShowVi
bucketlist: bucketlist,
followers: followers
});
view.render();
});
除了视图(顶部代码的第一段代码)之外,我可以在任何地方检索关注者。
console.log以及console.log(bucketlist.followers)返回undefined。
答案 0 :(得分:0)
好的(和女士们),我必须为模型创建骨干关联。这就是诀窍。