dongsu1539 2011-11-01 18:50
浏览 47
已采纳

CakePHP 2.0 Livesearch

I'm trying to create this: http://www.justkez.com/cakephp-livesearch/ in CakePHP 2.0. The problem is that the AjaxHelper is not available anymore in CakePHP 2.0, and so

echo $this->Ajax->observeField('query', $options);

Does not work anymore.

Any suggestions?

  • 写回答

2条回答 默认 最新

  • douhu4091 2012-11-09 02:12
    关注

    I ended up implementing it using the JSHelper, like suggested above. I will be marking this as an answer, since it contains the actual code example on how to do it.

    <h3>Search Reservations</h3>
    <?php
    echo $this->Html->css('screen');
    // we need some javascripts for this
    echo $this->Html->script('jquery');
    // create the form
    echo $this->Form->create(false, array('type' => 'get', 'default' => false));
    echo $this->Form->input('query', array('type' => 'text','id' => 'query', 'name' => 'query', 'label' => false))?>
    <div id="loading" style="display: none; ">
    <?php
    echo $this->Html->image('ajax_clock.gif');
    ?>
    </div>
    <?php
    $this->Js->get('#query')->event('keyup', $this->Js->request( 
    array('controller' => 'sales','action' => 'searchReservations', $event['Event']['id']), 
    array( 
    'update' => '#view', 
    'async' => true,
    'dataExpression' => true, 
    'method' => 'post', 
    'data' => $this->Js->serializeForm(array('isForm' => false, 'inline' => true))) 
    ));
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口