2

With the new CanJS update, my Models stopped working and I dont know why.

This is what my code looks like:

    Module = can.Model.extend({
           findAll: 'GET ' + window.rootPath+'api/module'
    }, {});

    FormModule = can.Control.extend({}, {
    init: function (element, options) {
        var self = this;

        Module.findAll({}, function (data) {
            self.element.html(can.view('viewModulesResult', data));               
        },            
        function (data) {
            console.log(data);               
        });                 
    }        
    });

Since I'm starting with javascript, I'm not very good at it, so I have no idea of whats wrong. When I pass the mouse over console.log(data) in the Console, this message appears: "Could not get any raw data while converting using .models" Does anyone knows whats wrong?

ramblinjan
  • 6,578
  • 3
  • 30
  • 38
Glund
  • 507
  • 1
  • 5
  • 20
  • 1
    Using the console, can you catch the GET request going to your /api/module url and the response. Is it an array of Module objects ? – Thomas Oct 30 '13 at 22:39

1 Answers1

0

The return isn't an array. can.Model.parseModels should be used to convert the ajax responses into a data format useful to can.Model.models. Reference: http://canjs.com/docs/can.Model.parseModels.html