1

我想在四个链接的一个区域上传数据,当我单击链接1时,它将加载特定区域的数据,当我单击链接2时,它将在第一个链接打开的同一区域加载页面,怎么能我这样做?

    <div class="container">
    <div class="span-5">
        <ul>
            <li><?php echo $this->Manager->link('Ecommerce',array('controller'=>'associations','action'=>"view_report"),array('id'=> 'home','class'=>'nav'));?></li>
            <li><a href="#" id="home" class="nav">Home</a></li>
            <li><a href="#" id="about" class="nav">About</a></li>
            <li><a href="#" id="contact" class="nav">Contact Us</a></li>
        </ul>
    </div>
</div>

我想从电子商务链接打开的数据是 int newfile.ctp 这样的

 <?php v_start($this);?>

<h1><?php echo __l('View Report');?></h1>

<div class="firsttable">
    <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <thead>
          <tr class="heading">
            <td><?php  echo __l('Financials');?></td>
            <td><?php  echo __l('Payment Methods');?></td>
            <td><?php  echo __l('By Credit Card');?></td>
          </tr>
        </thead>
        <tbody>  

          <tr>
            <td>
                <?php 
                    echo __l("YTD \t ");
                    $ytd_total=0;
                    foreach ($YTD as $yearData)
                    {

                        $ytd_total +=$yearData['AssocPaymentDetail']['membership_fee'] - $yearData['AssociationDiscount']['amount'];

                    }
                    echo  $ytd_total."<br />";

                ?>
                <?php

                echo __l("Last 5days ");
                 $fda_total= 0;
                 foreach ($fiveDays as $fiveDaysData)
                    {

                        $fda_total += $fiveDaysData['AssocPaymentDetail']['membership_fee'] - $fiveDaysData['AssociationDiscount']['amount'];

                    }
                    echo $fda_total ."<br />";
                 ?> 
            </td>
            <td><?php  echo __l('creditcard');?>  <?php echo __l($ccSum) ?> </td>
            <td>
                <?php
        //       debug($paymentRecord);
        //      debug($ccIndex);
                    foreach($paymentRecord as $data =>$key){
                        foreach($ccIndex as $index){
                            if($data== $index)
                            {
                                echo "$data \t\t\t";
                                if(is_array($key))
                                    echo array_sum($key);
                                else 
                                    echo "\t\t $key";


                            }

                            echo "<br/>";
                        }   

                    }

                ?>
            </td>
          </tr>
        </tbody>  
    </table>
</div>

请帮我这样做,在此先感谢

4

4 回答 4

3

好吧,我没有使用任何额外的 jquery 就做到了

<div class="container">
 <div class="span-5">
    <ul>
        <li><?php echo $this->Manager->link('Ecommerce',array('controller'=>'associations','action'=>"view_report"),array('update'=> '#testDiv'));?>li>
        <li><a href="#" id="home" class="nav">Home</a></li>
        <li><a href="#" id="about" class="nav">About</a></li>
        <li><a href="#" id="contact" class="nav">Contact Us</a></li>
    </ul>
   </div>
   </div>
 <div id = 'testdiv'></div>

cake 将使用 cake 的属性更新,自行更新区域。非常感谢回答这个问题的人,无论答案是对还是错。谢谢大家

于 2013-02-27T12:46:18.377 回答
1

将链接放入 href 属性中,然后通过 jquery 处理它们,如下所示

$('a.nav').click(function(e){
 e.preventDefault();
 $.get($(this).attr('href'), function(data){
  $cont = $('[CONTAINERS SELECTOR]');
  $cont.html(data);
 })
})

评论后编辑

将您的 html 更改为这样的内容

<div class="container">
<div class="innerCont"></div>
    <div class="span-5">
        <ul>
            <li><?php echo $this->Manager->link('Ecommerce',array('controller'=>'associations','action'=>"view_report"),array('id'=> 'home','class'=>'nav'));?></li>
            <li><a href="#" id="home" class="nav">Home</a></li>
            <li><a href="#" id="about" class="nav">About</a></li>
            <li><a href="#" id="contact" class="nav">Contact Us</a></li>
        </ul>
    </div>

并将内容选择器放到div.innerCont

$cont = $('div.innerCont');
于 2013-02-27T09:50:10.910 回答
1

你没有在你的 html 中指定区域,这里我假设它就在你的 ul 节点之后

$uls = $("ul.span5"); // select all page ul.span5
$uls.each(function(){ // for all ul.span5 node
    $ul = $(this); // current ul to work
    $region = $("<div/>").insertAfter($ul); // dynamic create and insert the region, as a div
    $links = $ul.find("a.nav"); // select all sub links
    $links.click(function(e){ // click on links
        $a = $(this); // current link
        var href = $a.attr("href"); // i assume you work on the href
        $region.load("myajax.php",{href:href},function(data){ // do ajax and load it in the common region
            // here load is done, do next step here
        });
        e.preventDefault(); // no real click please
    });
});
于 2013-02-27T09:56:27.080 回答
1

您可以将单个请求处理程序附加到具有nav类名的所有链接,然后将输出加载到容器

$(".nav").on('click', function() {
    $("#loadingdiv").load("linktoload.php"); // or other 

});
于 2013-02-27T10:04:29.313 回答