1

I have an edit view for a Backbone Model that I create each time the the element is clicked on. The problem I have is that the edit view needs two Backbone collections to create the edit form (it contains two <select> lists).

The view:

MyApp.elementView = Backbone.View.extend({
    events: {
            'click .edit': 'editForm',
    },
    editForm: function(ev) {

            var editView = new TimeTrack.Views.EditJob({
                model: this.model
                // This view needs two more collections
                // for the <select> elements
            });
            ...
    }
});

Instantiate the view:

var elementView = new MyApp.elementView({
        collection: elementCollection
});

What is the best way to push the needed collections to the edit view? Do I have to pass the collections need for the edit view from the elementView form the instantiation? Or is there a better way of doing this?

1 Answer 1

3

I did so, passed in view 2 collections, 1 - the main and the other as follows: to elementView - second collection and in elementView recive her.

example: in router I'm

initialize: ->
  (YourNameSpace).secondCollection = new (YourNameSpace).secondCollection

 elements: =>
    view = new (YourNameSpace).elementView( secondCollection: @secondCollection )
    $('.l-yield').html(view.render().el)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.