dsljpwi494719 2014-08-20 11:52
浏览 57
已采纳

yii datepicker renderpartial ajax - 第4个参数为true但不工作

Wenn i'm loading the view via ajax the datepicker wont work. I already set every single .js and .css file via setclientscript to false on ajaxRequest.

  Yii::app()->clientScript->scriptMap['jquery.js'] = false;
  and the other files as well....

Wenn i check the source code the datepicker input fields are registered

/*<![CDATA[*/
 jQuery(function($) {
jQuery('#date_from').datepicker({'showAnim':'fold'});
jQuery('#date_to').datepicker({'showAnim':'fold'});
...

I also set the renderPartial 4th param to true

  $this->renderPartial('my_view', array(some variables...), false, true);

I also gave evry datepicker on the page a unique ID. That helped neither.

When i reload the page everythign works fine, but via ajaxRequest the datepicker doesnt appear... thats pretty strange

SOLUTION EDIT:

i put at the end of my view the following code:

EDIT: GOT THE SOLUTION:

i put at the bottom of my view:

$("#my_datepicker").removeClass("hasDatepicker");
$("#my_datepicker").datepicker("destroy");
$("#my_datepicker").datepicker();
  • 写回答

1条回答 默认 最新

  • dryk50495 2014-08-20 12:38
    关注

    Adding as answer to accept

    After Ajax request reinitialize your datepicker simply by recalling it once more:

    $("#my_datepicker").datepicker("destroy");
    $("#my_datepicker").datepicker();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等