+ -
当前位置:首页 → 问答吧 → jquery sortable的一个问题

jquery sortable的一个问题

时间:2010-04-01

来源:互联网

我需要把兴趣爱好的顺序排号,然后存入数据库里面,数据库没有区别什么兴趣,都放在一起。
我的view的代码:
复制代码
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  5.         <link rel="stylesheet" href="<?php echo base_url().$this->config->item('FAL_theme_css') ?>" type="text/css" />
  6.         <script type='text/javascript' src="<?php echo base_url().$this->config->item('FAL_theme_jquery') ?>"></script>
  7.         <script type='text/javascript' src="<?php echo base_url().$this->config->item('FAL_theme_ui_core') ?>"></script>
  8.         <script type='text/javascript' src="<?php echo base_url().$this->config->item('FAL_theme_ui_sortable') ?>"></script>
  9.         <title>Interest</title>
  10. </head>
  11. <ul id="interest">
  12.         <ul class="content" id="interest-1">
  13.                 <h1>sports</h1>
  14.                 <li id="content-1">football</li>
  15.                 <li id="content-2">basketball</li>
  16.                 <li id="content-3">swimming</li>
  17.                 <li id="content-4">fishing</li>
  18.         </ul>
  19.         <ul class="content" id="interest-2">
  20.                 <h1>life-style</h1>
  21.                 <li id="content-5">shoping</li>
  22.                 <li id="content-6">cooking</li>
  23.                 <li id="content-7">working</li>
  24.                 <li id="content-8">flying</li>
  25.         </ul>
  26. </ul>
  27. <script language="javascript"> 
  28.         $('.content').sortable({
  29.                 delay:1,
  30.                 stop:function(){
  31.                         $.post(
  32.                                 "my/test2",        
  33.                                 $('.content').sortable('serialize'),
  34.                                 function(response){
  35.                                         alert(response);
  36.                                 }
  37.                         );
  38.                 }
  39.         });
  40. </script>
  41. <?php $this->load->view('html/footer'); ?> 

我的controller的代码:
复制代码
  1. function test(){
  2.   $this->load->view('html/test');
  3. }
  4. function test2(){
  5.   $str = implode(",", $_POST['content']);
  6.   echo $str;
  7. }

我想在传顺序值的时候,需要把第二个ul(life-style)的值也能传到test2,但是每次都只是alert 第一个ul的值。有什么办法可以把所有class等于content的li的值都能post到test2.


可以看到我已经移动了第二个ul2,但alert的值没有超过5678
不知道大家有没有遇到过这样的情况,希望大家能帮帮忙。。。谢谢。。。。

作者: fanxuan   发布时间: 2010-04-01