4

Gravity Forms で gform_post_render 関数を使用して、1 日前を選択するための minDate オプションを使用してカスタム日付ピッカーを作成しました。

http://www.gravityhelp.com/documentation/page/Gform_post_render

週末を除外する方法はありますか? ユーザーが 1 日先の平日のみを選択できるようにしたい。を使用してみましたbeforeShowDay: $.datepicker.noWeekendsが、競合しているようですminDate

ここに私のフォームがあります: http://www.discountdumpsters.com/shop/30-yard-dumpster/

そして、ここに私のコードがあります:

<script type="text/javascript">
jQuery(document).bind('gform_post_render', function(){
    // destroy default Gravity Form datepicker
    jQuery("#input_1_1").datepicker('destroy');
    // create new custom datepicker
    jQuery("#input_1_1").datepicker({ defaultDate: '+1d', minDate: '+1d',     gotoCurrent: true, prevText: '', showOn: 'both', buttonImage: 'http://www.discountdumpsters.com/wp-content/plugins/gravityforms/images/calendar.png',    buttonImageOnly: true });
});
</script>

助けていただければ幸いです...ありがとう!

4

3 に答える 3

0

頭ではなくフッターにスクリプトをエンキューする必要があると思います

于 2012-10-23T12:23:13.123 に答える
0

実際、私はあなたのコードを外部jsファイルで使用しましたが、noweekends宣言でも機能しています

jQuery(document).bind('gform_post_render', function(){
// destroy default Gravity Form datepicker
jQuery(".datepicker").datepicker('destroy');
// create new custom datepicker
jQuery(".datepicker").datepicker({ 
    defaultDate: '+1d', 
    minDate: '+1d',  
    gotoCurrent: true, 
    prevText: '', 
    showOn: 'both', 
    buttonImage: '/wp-content/themes/teloaggiustoio/images/calendar_icon.png',    
    buttonImageOnly: true,  
    beforeShowDay: $.datepicker.noWeekends

}); });
于 2012-12-27T16:07:04.607 に答える
0

この質問に答えたことがないことに気づきました。これが私のために働いた最終的なコードです:

jQuery(document).bind('gform_post_render', function(){
    // destroy default Gravity Form datepicker
    jQuery("#input_1_1").datepicker('destroy');
    // create new custom datepicker
    var oneWorkingDays = new Date();
    var adjustments = [0, 1, 1, 1, 1, 1, 0]; // Offsets by day of the week
    oneWorkingDays.setDate(oneWorkingDays.getDate() + 1 + adjustments[oneWorkingDays.getDay()]);
    jQuery("#input_1_1").datepicker({ beforeShowDay: jQuery.datepicker.noWeekends, minDate: '+1d', gotoCurrent: true, prevText: '', showOn: 'both', buttonImage: '/wp-content/plugins/gravityforms/images/calendar.png', buttonImageOnly: true });
});
于 2013-12-12T19:33:42.617 に答える