Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

In backbone js I want to pass two model to view while creating object of a view. Also please tell me from that view how to fetch each of that model.The code which I have written in controller js is as follows

var clientModel = new ClientModel();
var allClientModel = new AllClientModel();
var clientView = new ClientView({model:clientModel});


I want to pass allClientModel object as well to the view.Please tell me what is the syntax for that.

Thanks in advance

What I have tried:

I tried to write the code which is as follows

var clientView = new ClientView({model1:clientModel,model2:allClientModel });

But it is not working
Posted
Updated 17-Jun-16 3:41am

1 solution

JavaScript
var Passingmodel = new Backbone.Model(); // BackBone Model
var clientModel = new ClientModel(); // Client Model
var allClientModel = new AllClientModel(); // All Client Model 

Passingmodel .set({contacts: clientModel , users: allClientModel });

var clientView = new ClientView({model: Passingmodel });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900