jquery - Javascript plugin appending duplicate data in Wordpress -


i'm using currency conversion plugin called curry.js that's being called on custom wordpress page bootstrap tabs , advanced custom fields.

as wp loops through each tab it's appending list of currencies when open dropdown in third tab see list of currencies repeated 3 times.

here's portion of code curry.js running each time:

var generateddm = function( rates ){          output = '';          // change target elements drop downs         dropdownmenu.each(function(){              (var in rates ) {                  rate = rates[i];                  output += '<option value="'+ +'" data-rate="'+ rate +'">' + + '</option>';              }              $( output ).appendto( );          });      }; 

i've tried creating counter variable outside block of code after runs once , creates list of currencies, stores list in global output variable no longer appended to, no avail.

if further clarification needed, i'm happy provide--any fantastic i've spend many hours trying figure out , know should simple solution.

thanks!

solved simple if statement checking length of output variable after each wp loop:

dropdownmenu.each(function(){   if(output.length < 251) {     ( var in rates ) {       rate = rates[i];                   output += '<option value="'+ +'" data-rate="'+ rate +'">' + + '</option>';     }     $( output ).appendto( );   }   else {     $( output ).appendto( );   } }); 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -