ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.03k stars 1.2k forks source link

$.extend and gridster configuration object #402

Open mbana opened 10 years ago

mbana commented 10 years ago

Is this behaviour intentional?

var ResizeHandler = function() {
this.enabled = true;
};
var handler = new ResizeHandler();

var GridConfig = function() {
this.resize = handler;
};
var gConfig = new GridConfig();

var newOptions = $.extend(true, {}, defaults, gConfig);

JSON.stringify(newOptions);
"{"namespace":"","widget_selector":"li","widget_margins":[10,10],"widget_base_dimensions":[400,225],"extra_rows":0,"extra_cols":0,"min_cols":1,"max_cols":null,"min_rows":15,"max_size_x":false,"autogrow_cols":false,"autogenerate_stylesheet":true,"avoid_overlapped_widgets":true,"collision":{},"draggable":{"items":".gs-w","distance":4},"resize":{"enabled":true}}"

JSON.stringify(newOptions.resize);
"{"enabled":true}"

JSON.stringify(defaults.resize);
"{"enabled":false,"axes":["both"],"handle_append_to":"","handle_class":"gs-resize-handle","max_size":[null,null],"min_size":[1,1]}"

As you can see from above, it's omitted a lot of the default options for the resize property.