Yii: Using the Cjuidatepicker date control in Ajax refreshes

Source: Internet
Author: User
If the Cjuidatepicker component is used in the Ajax update interface, note that the jquery UI DatePicker JS initialization script needs to be re-executed for the date control to take effect.

In addition, the DatePicker control relies on the jquery UI plug-in, so you need to register the jquery ui css and JS files. The specific code is as follows:

 
  Getclientscript ()->registercorescript (' jquery ');    Yii::app ()->getclientscript ()->registercorescript (' Jquery.ui ');     Yii::app ()->clientscript->registercssfile (        Yii::app ()->clientscript->getcorescripturl ().        /jui/css/base/jquery-ui.css '    );       Yii::app ()->clientscript->registercssfile (        Yii::app ()->clientscript->getcorescripturl ().        /jui/css/base/jquery.ui.datepicker.css '    );  ? >

Reinstall the date control initialization script:

$.ajax ({URL: '
 
   url?> ',type: ' Post ',data: ' &days= ' + days,  DataType: ' text ',success:function (data) {  $ ("#list"). HTML (data);          $ (' #begin_time '). DatePicker (Jquery.extend ({showmonthafteryear:false}, Jquery.datepicker.regional[' cn '],{' DateFormat ': ' Yy/mm/dd '});            }});

If you are using a date control in Cgridview, you can put the reinitialized operation in the Afterajaxupdate callback.

The above describes Yii: using the Cjuidatepicker date control in Ajax refresh, including the content of the aspects, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.