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.