title: Generate JS function in loop
body: <p>I would like generate js function in loop, but I have problem. Please, can anybody tell that my thinking is right ? It's is possible to generate functions in loop?</p>
  
  <pre><code>var sortItems =
                      ["sortable11","sortable12","sortable13","sortable14","sortable15",
                      "sortable21","sortable22","sortable23","sortable24","sortable25",
                      "sortable31","sortable32","sortable33","sortable34","sortable35",
                      "sortable41","sortable42","sortable43","sortable44","sortable45",
                      "sortable51","sortable52","sortable53","sortable54","sortable55"];
                  for ( key in sortItems) {
                      $(function(){
                          $('#' + sortItems[key]).sortable({
                              update: function(event, ui)
                              {
                                  $.ajax({
                                      type: "POST",
                                      url: "fun/saveOrder.php",
                                      dataType: "text",
                                      data: 
                                          {
                                          key:$(this).sortable('toArray')
                                      },
                                      cache: false,
                                      beforeSend: function(){$('#updateResult').html('updating');},
                                      success: function(data){$('#updateResult').html(data);},
                                      error: function(data){$('#updateResult').html(data);}
                                  })
                                  recalculate();
                              }
                          })
                      })
                  }
  </code></pre>