From 5f028edeb042004b21f5751a35459d60a09b0283 Mon Sep 17 00:00:00 2001 From: Gabriel Jenik Date: Tue, 6 Feb 2018 15:07:03 -0300 Subject: [PATCH] Update jquery.counterup.js Avoid errors. Sometimes this code is run even when there is no counterup-nums Seems to happen when loading wihtut the counter in the view and then showing it --- jquery.counterup.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery.counterup.js b/jquery.counterup.js index bc7871f..14c582c 100644 --- a/jquery.counterup.js +++ b/jquery.counterup.js @@ -59,6 +59,10 @@ // Updates the number until we're done var f = function() { + // Avoid errors. Sometimes this code is run even when there is no counterup-nums + // Seems to happen when loading wihtut the counter in the view and then showing it + if (!$this.data('counterup-nums')) return; + $this.text($this.data('counterup-nums').shift()); if ($this.data('counterup-nums').length) { setTimeout($this.data('counterup-func'), $settings.delay); @@ -80,4 +84,4 @@ }; -})( jQuery ); \ No newline at end of file +})( jQuery );