0
votes

When I use ember-1.0.0-pre.4.min.js on my code, I get the following errors from Chrome's console debugger:

Uncaught TypeError: Object prototype may only be an Object or null ember-1.0.0-pre.4.min.js:18 Uncaught TypeError: Cannot call method 'extend' of undefined

Code:

Win = Em.Application.create({                
    View: {}, 
    Model: {},
    Controller: {}
});

Win.Model.ValuePair = Em.Object.extend({
    id: null,
    name: null
});

Win.View.BrandKeywordView = Em.TextField.extend({
    keyDown: function () {
        var value = this.get('value');

        if (value) {
            Win.Controller.BrandKeywordController.searchBrand(value);
            console.log(Win.Controller.BrandKeywordController.content[0].id);
        }
    }
});

Win.Controller.BrandKeywordController = Em.ArrayProxy.create({
    content: [],

    searchBrand: function (brandName) {
        var me = this;
        $.ajax({
            type: "POST",
            dataType: "json",
            contentType: 'application/json; charset=utf-8',
            url: 'brands/default.aspx/Search',
            data: '{keyword:"' + brandName + '"}',
            success: function (data) {
                var brands = $.parseJSON(data.d);
                me.content = [];
                for (var i = 0, max = brands.length; i < max; i++) {
                    me.pushObject(Win.Model.ValuePair.create({ id: brands[i].Id, name: brands[i].Name }));
                }
            }
        });
    }
});

But then everything works fine when I switch to ember-1.0.beta.2.min.js.

What am I doing wrong?

Which release should I use?

Thanks in advance.

1

1 Answers

0
votes

Without having studied your code in detail, my guess would be the routing API. It has completely changed between pre2 and pre3, thus is not backward compatible. Have a look at http://emberjs.com/guides/routing/

So, you really need to "migrate" your code to the new version. It will not just work with the new versions.

NOTE that the API has been freezed with pre4. So, API backward compatibility issues should not arise anymore 'til the next major version of ember js.