Can someone help me in backbone.js RRS feed

  • Question

  • User-873890331 posted

    Hi All,

    How to get model from server and display on view ?

    I have already get the collection from server and displayed on view. Now I want to get details of single item when i pass Id to server. First I am getting collection and display in a grid. Now If someone clicks on gridview row then I passes id in url. I want to get Model by passing this Id. What I do to get Model. I am getting Error -  Uncaught TypeError: Cannot read property 'get' of undefined

    ************ Model start ************************

    ], function ($, _, Backbone) {
        var Order = Backbone.Model.extend({
            idAttribute: "ID",
        return Order;

    ************* Model End **************************

    *************** View Start ***********************

    ], function ($, _, Backbone, orderDetails, OrderCollection, ItemCollection,Orders) {
        var ProfileView = Backbone.View.extend({
            el: $("#content"),
            render: function (Id) {
                this.Id = Id;
                var self = this;
                this.order = new Orders();
                    url: 'GetOrderDetails',
                    data: JSON.stringify({ orderId: window.Id }),
                    success: function () {
                    error: function (a, b, c) {
            renderList: function () {
                var compiledTemplate = _.template(orderDetails, { Details: this.order, Items: this.order.Items });
        return ProfileView;

    *************** View End ************************

    Can someone help me regarding this issue.

    Thanks & Regards


    Wednesday, June 4, 2014 3:10 PM


  • User1402382751 posted

    I have already get the collection from server and displayed on view

    Dude, you got list of models(collection) from the server, so use the Collection.get(id) method to get the model details from the collection and display in the view for the model


    If your collections have a view, then your context for the click event is the collection itself, so you can use that method of collection object. use


    to your help to find which objects are passed on to your click event callback

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 8, 2014 1:31 AM