@@ -60,7 +60,7 @@ <h1>Serialization demo</h1>
6060 $ ( '.grid-stack' ) . gridstack ( options ) ;
6161
6262 new function ( ) {
63- this . serialized_data = [
63+ this . serializedData = [
6464 { x : 0 , y : 0 , width : 2 , height : 2 } ,
6565 { x : 3 , y : 1 , width : 1 , height : 2 } ,
6666 { x : 4 , y : 1 , width : 1 , height : 1 } ,
@@ -73,17 +73,18 @@ <h1>Serialization demo</h1>
7373
7474 this . grid = $ ( '.grid-stack' ) . data ( 'gridstack' ) ;
7575
76- this . load_grid = function ( ) {
77- this . grid . remove_all ( ) ;
78- var items = GridStackUI . Utils . sort ( this . serialized_data ) ;
76+ this . loadGrid = function ( ) {
77+ this . grid . removeAll ( ) ;
78+ var items = GridStackUI . Utils . sort ( this . serializedData ) ;
7979 _ . each ( items , function ( node ) {
80- this . grid . add_widget ( $ ( '<div><div class="grid-stack-item-content" /><div/>' ) ,
80+ this . grid . addWidget ( $ ( '<div><div class="grid-stack-item-content" /><div/>' ) ,
8181 node . x , node . y , node . width , node . height ) ;
8282 } , this ) ;
83+ return false ;
8384 } . bind ( this ) ;
8485
85- this . save_grid = function ( ) {
86- this . serialized_data = _ . map ( $ ( '.grid-stack > .grid-stack-item:visible' ) , function ( el ) {
86+ this . saveGrid = function ( ) {
87+ this . serializedData = _ . map ( $ ( '.grid-stack > .grid-stack-item:visible' ) , function ( el ) {
8788 el = $ ( el ) ;
8889 var node = el . data ( '_gridstack_node' ) ;
8990 return {
@@ -93,18 +94,20 @@ <h1>Serialization demo</h1>
9394 height : node . height
9495 } ;
9596 } , this ) ;
96- $ ( '#saved-data' ) . val ( JSON . stringify ( this . serialized_data , null , ' ' ) ) ;
97+ $ ( '#saved-data' ) . val ( JSON . stringify ( this . serializedData , null , ' ' ) ) ;
98+ return false ;
9799 } . bind ( this ) ;
98100
99- this . clear_grid = function ( ) {
100- this . grid . remove_all ( ) ;
101+ this . clearGrid = function ( ) {
102+ this . grid . removeAll ( ) ;
103+ return false ;
101104 } . bind ( this ) ;
102105
103- $ ( '#save-grid' ) . click ( this . save_grid ) ;
104- $ ( '#load-grid' ) . click ( this . load_grid ) ;
105- $ ( '#clear-grid' ) . click ( this . clear_grid ) ;
106+ $ ( '#save-grid' ) . click ( this . saveGrid ) ;
107+ $ ( '#load-grid' ) . click ( this . loadGrid ) ;
108+ $ ( '#clear-grid' ) . click ( this . clearGrid ) ;
106109
107- this . load_grid ( ) ;
110+ this . loadGrid ( ) ;
108111 } ;
109112 } ) ;
110113 </ script >
0 commit comments