Explorar o código

New event for sections (load/unload)

@soyjavi %!s(int64=14) %!d(string=hai) anos
pai
achega
a12edd29f5
Modificáronse 2 ficheiros con 16 adicións e 2 borrados
  1. 14 0
      examples/kitchen-sink/app/events.js
  2. 2 2
      src/router/Lungo.Router.js

+ 14 - 0
examples/kitchen-sink/app/events.js

@@ -6,6 +6,7 @@ App.Events = (function(lng, undefined) {
     });
     */
 
+
     lng.dom('#event_touchstart').touch(function(event) { alert("touchstart!"); });
     //OR
     //lng.dom('#event_touchstart').on('touchstart', function(event) { alert("TOUCH_START!"); });
@@ -31,4 +32,17 @@ App.Events = (function(lng, undefined) {
     });
 
 
+    //SPECIAL
+    $$('section#navigation').on('load', function(event) {
+        console.error('Load #navigation', event);
+    });
+
+    $$('section#navigation').on('unload', function(event) {
+        console.error('Unload', event);
+    });
+
+    $$('article#authors').on('load', function(event) {
+        console.error('loaded article');
+    });
+
 })(LUNGO);

+ 2 - 2
src/router/Lungo.Router.js

@@ -28,7 +28,7 @@ LUNGO.Router = (function(lng, undefined) {
 
         if (_existsTarget(target)) {
             lng.dom(_getHistoryCurrent()).removeClass(CSS_CLASSES.SHOW).addClass(CSS_CLASSES.HIDE);
-            lng.dom(section_id).addClass(CSS_CLASSES.SHOW);
+            lng.dom(target).addClass(CSS_CLASSES.SHOW).trigger('load');
 
             lng.Router.History.add(section_id);
         }
@@ -56,7 +56,7 @@ LUNGO.Router = (function(lng, undefined) {
      * @method back
      */
     var back = function() {
-        lng.dom(_getHistoryCurrent()).removeClass(CSS_CLASSES.SHOW);
+        lng.dom(_getHistoryCurrent()).removeClass(CSS_CLASSES.SHOW).trigger('unload');
         lng.Router.History.removeLast();
 
         lng.dom(_getHistoryCurrent()).removeClass(CSS_CLASSES.HIDE).addClass(CSS_CLASSES.SHOW);