$(function() {
var Shape = Backbone.Model.extend({
defaults : {
x : 100,
y : 100,
width : 100,
height : 100,
color : 'green'
},
setTopLeft : function(x, y) {
this.set({
x : x,
y : y
});
},
setDim : function(w, h) {
this.set({
width : w,
height : h
});
}
}); ... });
In this JS example I used $(function()...). If I remove this outer function line from the code, my program doesn't work. Why do I have to use it? Is this problem related with the "document ready"?
Also I have a code which works well without "$(function()...)".
var AppView = Backbone.View.extend({
el : '#container',
initialize : function() {
this.render();
},
render : function() {
this.$el.html("Hello World");
}
});
var appView = new AppView();
What's the difference between two codes? I hava no idea at all...
plz help this poor student... ;(