[Commits] r2482 - in core/trunk/geoext: lib/GeoExt/data tests/lib/GeoExt/data

commits at geoext.org commits at geoext.org
Wed Nov 17 13:12:27 CET 2010


Author: ahocevar
Date: 2010-11-17 13:12:27 +0100 (Wed, 17 Nov 2010)
New Revision: 2482

Modified:
   core/trunk/geoext/lib/GeoExt/data/LayerStore.js
   core/trunk/geoext/tests/lib/GeoExt/data/LayerStore.html
Log:
giving the LayerStore a bind event. r=fredj (closes #376)


Modified: core/trunk/geoext/lib/GeoExt/data/LayerStore.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/data/LayerStore.js	2010-11-17 11:08:56 UTC (rev 2481)
+++ core/trunk/geoext/lib/GeoExt/data/LayerStore.js	2010-11-17 12:12:27 UTC (rev 2482)
@@ -106,6 +106,18 @@
             var options = {initDir: config.initDir};
             delete config.initDir;
             arguments.callee.superclass.constructor.call(this, config);
+            
+            this.addEvents(
+                /** api:event[bind]
+                 *  Fires when the store is bound to a map.
+                 *
+                 *  Listener arguments:
+                 *  * :class:`GeoExt.data.LayerStore`
+                 *  * ``OpenLayers.Map``
+                 */
+                "bind"
+            );
+            
             if(map) {
                 this.bind(map, options);
             }
@@ -162,6 +174,7 @@
                 "replace" : this.onReplace,
                 scope: this
             });
+            this.fireEvent("bind", this, map);
         },
 
         /** private: method[unbind]

Modified: core/trunk/geoext/tests/lib/GeoExt/data/LayerStore.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/data/LayerStore.html	2010-11-17 11:08:56 UTC (rev 2481)
+++ core/trunk/geoext/tests/lib/GeoExt/data/LayerStore.html	2010-11-17 12:12:27 UTC (rev 2482)
@@ -132,7 +132,7 @@
         }
         
         function test_bind_unbind(t) {
-            t.plan(28);
+            t.plan(29);
             
             var map = new OpenLayers.Map("mappanel");
             var store = new GeoExt.data.LayerStore();
@@ -166,6 +166,10 @@
             
             // test store to map synchronization
             reinit_test_data();
+            store.on("bind", function(s, m) {
+                // test if the bind event works
+                t.eq(m.id, map.id, "bind event triggered with the correct map.");
+            }, null, {single: true});
             store.bind(map, {initDir: GeoExt.data.LayerStore.STORE_TO_MAP});
             t.eq(map.layers.length, 4, "initial records are synchronized to map");
             t.eq(store.getCount(), 2, "initial layers are not synchronized to store");



More information about the Commits mailing list