]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#469] Fixed error throwing to use Popcorn.error and also switched to using setTimeou...
authorDavid Seifried <david.c.seifried@gmail.com>
Fri, 3 Jun 2011 19:28:35 +0000 (15:28 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Fri, 3 Jun 2011 19:28:35 +0000 (15:28 -0400)
plugins/mustache/popcorn.mustache.js

index a39e19b63223d22e8e9e1fb1cdfe72e32e209461..90256d31e81633e4eff8a379633085ab1117aa3b 100644 (file)
     } else if ( typeOfTemplate === 'string' ) {
       template = options.template;
     } else {
-      throw 'Mustache Plugin Error: options.template must be a String or a Function.';
+      Popcorn.error( 'Mustache Plugin Error: options.template must be a String or a Function.' );
     }
 
     if ( typeOfData === 'function' ) {
     } else if ( typeOfData === 'object' ) {
       data = options.data;
     } else {
-      throw 'Mustache Plugin Error: options.data must be a String, Object, or Function.';
+      Popcorn.error( 'Mustache Plugin Error: options.data must be a String, Object, or Function.' );
     }
 
     return {
       start: function( event, options ) {
 
-        var interval = window.setInterval( function() {
-
-          if( loaded ) {
-
-            window.clearInterval( interval );
+        var interval = function() {
+          
+          if( !loaded ) {
+            setTimeout( function() {
+              interval();
+            }, 10 );
+          } else {
 
             // if dynamic, freshen json data on every call to start, just in case.
             if ( getData ) {
                                        ).replace( /^\s*/mg, '' );
             document.getElementById( options.target ).innerHTML = html;
           }
-        }, 10 );
+        }
+
+        interval();
+
       },
 
       end: function( event, options ) {