JQuery Datepicker未在我的结帐页面上显示

时间:2013-03-28 12:58:52

标签: php jquery datepicker woocommerce

jQuery datepicker没有显示在我的结帐页面上,我无法弄清楚原因。

出现交货日期字段,但是当您单击日期选择器时未显示。

我真的很感激任何想法如何解决这个问题!

以下是代码:

`

$wpefield_version = '1.0';

add_action('woocommerce_after_checkout_billing_form', 'my_custom_checkout_field'); 

function my_custom_checkout_field( $checkout ) {    

    wp_enqueue_script( 'jquery-ui-datepicker' );

    wp_enqueue_style( 'jquery-ui', "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" , '', '', false);
wp_enqueue_style( 'datepicker', plugins_url('/css/datepicker.css', __FILE__) , '', '', true);

/*print(' <link rel="stylesheet" type="text/css" href="' . plugins_url() . '/order-delivery-date-for-woocommerce/datepicker.css">

        <script type="text/javascript" src="' . plugins_url() . '/order-delivery-date-for-woocommerce/datepicker.js"></script>'
    );
print('<script type="text/javascript" src="' . plugins_url() . '/order-delivery-date-for-woocommerce/initialize-datepicker.js"></script>');*/

echo '<script language="javascript">jQuery(document).ready(function(){
jQuery("#e_deliverydate").width("150px");
var formats = ["MM d, yy","MM d, yy"];
jQuery("#e_deliverydate").val("").datepicker({dateFormat: formats[1], minDate:1});
jQuery("#e_deliverydate").parent().after("<div id=\'order-desc\'><small style=font-size:10px;>Format (DD/MM/YY). We will try our best to deliver your order on the specified date</small></div>");

;`

1 个答案:

答案 0 :(得分:0)

看看这里:http://jqueryui.com/datepicker/ 改变这个:

echo '<script language="javascript">jQuery(document).ready(function(){
jQuery("#e_deliverydate").width("150px");
var formats = ["MM d, yy","MM d, yy"];
jQuery("#e_deliverydate").val("").datepicker({dateFormat: formats[1], minDate:1});
jQuery("#e_deliverydate").parent().after("<div id=\'order-desc\'><small style=font-size:10px;>Format (DD/MM/YY). We will try our best to deliver your order on the specified date</small></div>");

为此:

echo '<script language="javascript">jQuery(document).ready(function(){
jQuery("#e_deliverydate").width("150px");
var formats = ["MM d, yy","MM d, yy"];
jQuery("#e_deliverydate").datepicker({dateFormat: formats[1], minDate:1});
jQuery("#e_deliverydate").parent().after("<div id=\'order-desc\'><small style=font-size:10px;>Format (DD/MM/YY). We will try our best to deliver your order on the specified date</small></div>");

确保加载了jqueryui.js。从浏览器查看控制台,查找错误。