http://pastebin.ca/1996549
The pastebin link may help if my wording doesn't. I basically have a site that contains a bunch of custom sortables. Although the user can remove them no p开发者_如何学编程roblem - they can never add them.
Any time a sortable needs to be added to the site I have to write up a set of identical parameters and the only thing that changes is the ID number (you can see the example in my pastebin).
How could I set this up as a loop instead of some 2000 line javascript file that contains X amount of identical blocks.
You could supply an array of the IDs necessary from the database with PHP and get an AJAX routine to bring this back as a JSON array, then iterate over that.
<?php
// boxIDList.php
// Connect to the DB
include("config.php");
$resultboxone = mysql_query('SELECT id FROM `activejobs` WHERE active = 1');
$boxIDList = array();       
while($row = mysql_fetch_assoc($resultboxone))  {
  $boxIDList[] = $row['id'];
}
echo json_encode($boxIDList);
exit();
?>
The jQuery could then be as follows: (I'm not sure how you use your routines)
$.getJSON('boxIDList.php', function(boxIDs) {
   $.each(boxIDs, function(i, value) {
     boxspank(value);
     boxspanklist(value);
   });
});
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论