0

I'm trying to reuse a function for a undetermined number of div blocks that have similar id' but only differ by which number it is. For some reason this function is not working when count is greater that 1. Can someone tell where I went wrong?

    $(function() {
      for (i=0; i < {{count}}; i++)
       {
         $('#popout-'+i).dialog({
              autoOpen: false,
          });
         $("#apply_button_"+i).click(function() {
             $("#popout-"+i).dialog("open");
            });
        }
  });
Will-Opare
  • 73
  • 1
  • 2
  • 7
  • @squint I don't think that, this question is duplicate of what you marked – Zohaib Ijaz May 09 '16 at 17:48
  • @ZohaibIjaz: Yes, it's really just one of about 100,000 variations on the same question. Only difference is that yours is using an event handler to delay the execution, while the duplicate is executing it from an Array. The problem and solution are the same. –  May 09 '16 at 18:13
  • Here's [another duplicate](http://stackoverflow.com/questions/1451009/javascript-infamous-loop-issue) that uses event handlers like yours does. It too was closed as a dupe of the one that I used on yours. Either way, the solutions are given in those answers. –  May 09 '16 at 18:16
  • You are always here .. what do you do as full time job.. I know it's not an appropriate place to ask such a question. – Zohaib Ijaz May 09 '16 at 18:17
  • @ZohaibIjaz: Not actually here that often, except for research at times. Burned out on a project for the last few days, so here a little more than usual lately. Thought you were the OP above. Sorry about that. But that dupe is the standard answer for variations on this recurring question. –  May 09 '16 at 20:30

0 Answers0