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 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)