In backbonejs documentation it has been said that we can load bootstrapped models under loading bootstrapped models
So I did the same as there like
employeeCollection.reset(<%= @employees.to_json %>);
But I threw a error
Uncaught SyntaxError: Unexpected token &
When I clicked that error it took me to
employeeCollection.reset([{"address":"Madhyapur thimi 13, wamunae tole","fired":false,"first_name":"Gagan Shrestha","id":1,"last_name":"Shrestha","phone":"9841971919"},{"address":"Madhyapur thimi 13, wamunae tole","fired":true,"first_name":"Prem Krishna","id":2,"last_name":"Shrestha","phone":"9841755640"},{"address":"sdgd","fired":false,"first_name":"fdsfs","id":3,"last_name":"sfdsf","phone":"5345435"},{"address":"sdfsf","fired":true,"first_name":"dsfsd","id":4,"last_name":"fsd","phone":"sfdsf"},{"address":"Madhyapur thimi 13, wamunae tole","fired":false,"first_name":"Prafulla","id":5,"last_name":"Shrestha","phone":"9841971919"},{"address":"South africa","fired":false,"first_name":"ram","id":6,"last_name":"krishna","phone":"86879979"},{"address":"sdfdsf","fired":true,"first_name":"fs","id":7,"last_name":"sdfdsfdsf","phone":"sdfdsfds"},{"address":"juj","fired":true,"first_name":"rfr","id":8,"last_name":"hgtg","phone":"9898"},{"address":"gthy","fired":true,"first_name":"olo","id":9,"last_name":"plo","phone":"6766"},{"address":"rfrf","fired":true,"first_name":"uyuy","id":10,"last_name":"uyuy","phone":"7676"},{"address":"madhyapur thimi 12","fired":true,"first_name":"shuvam1","id":11,"last_name":"shrestha","phone":"1234556778"},{"address":"dodale","fired":true,"first_name":"sarita2","id":12,"last_name":"prajapati","phone":"985757"},{"address":"kathmandu","fired":false,"first_name":"hello","id":13,"last_name":"world","phone":"0155675432"}]);
I guess the error is due to escaping of json data, but not quite sure.
Do I need to do additional thing so that I can load necessary data when page loads, so that I need not fire ajax request to get those data from servers
Thanks