提示模式不能用作所述模式内变量的日期范围

问题描述 投票:1回答:1

在我的预订页面上,我选择2个日期范围,然后显示模式弹出窗口。我正在尝试在2个日期范围(即它们之间的天数,预订开始日期等)内的模式下工作。

在主页上执行此操作很好,但是我的值在模式弹出窗口中不起作用。我认为是因为我需要使用的值才是实际提示弹出窗口的值。

<!-- Modal -->


<div class="modal fade" id="owner_price_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog custom_price_dialog">
        <div class="modal-content">

            <div class="modal-header"> 
              <button type="button" id="close_custom_price_internal" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
              <h2 class="modal-title_big"><?php esc_html_e('Custom Price','wprentals');?></h2>
              <h4 class="modal-title" id="myModalLabel"><?php esc_html_e('Set custom price for selected period - test','wprentals');?></h4>
            </div>


            <div class="modal-body">

                <div id="booking_form_request_mess_modal"></div>    

                    <div class="col-md-6">
                        <label for="start_date_owner_book"><?php esc_html_e('Start Date','wprentals');?></label>
                        <input type="text" id="start_date_owner_book" size="40" name="booking_from_date" class="form-control" value="">




                    </div>

                    <div class="col-md-6">
                        <label for="end_date_owner_book"><?php  esc_html_e('End Date','wprentals');?></label>
                        <input type="text" id="end_date_owner_book" size="40" name="booking_to_date" class="form-control" value="">
                    </div>


                    <input type="hidden" id="property_id" name="property_id" value="" />
                    <input name="prop_id" type="hidden"  id="agent_property_id" value="">

                    <div class="col-md-6">
                        <label for="coment"><?php echo esc_html__( 'New Price in ','wprentals').' '.esc_html($wp_estate_currency_symbol);?></label>
                        <input type="text" id="new_custom_price" size="40" name="new_custom_price" class="form-control" value="">
                    </div>    


                <div class="col-md-6">
                    <label for="period_extra_price_per_guest"><?php echo wpestate_show_labels('extra_price_per_guest',$rental_type,$booking_type).' '.esc_html($wp_estate_currency_symbol);?></label>
                    <input type="text" id="period_extra_price_per_guest" size="40" name="period_extra_price_per_guest" class="form-control" value="0">
                </div> 

                <div class="col-md-6">
                    <label for="period_week_price"><?php  echo wpestate_show_labels('price_week_label',$rental_type,$booking_type);?></label>
                    <input type="text" id="period_week_price" size="40" name="period_week_price" class="form-control" value="">
                </div> 

                <div class="col-md-6">
                    <label for="period_month_price"><?php echo wpestate_show_labels('price_month_label',$rental_type,$booking_type);?></label>
                    <input type="text" id="period_month_price" size="40" name="period_month_price" class="form-control" value="">
                </div>       

                <div class="col-md-6">
                    <label for="period_price_per_weekeend"><?php echo esc_html__( 'Price per weekend in ','wprentals').' '.esc_html($wp_estate_currency_symbol);?></label>
                    <input type="hidden" id="period_price_per_weekeend" size="40" name="period_price_per_weekeend" class="form-control" value="">



                </div>
                     <div class="col-md-6">
                    <label for="period_min_days_booking"><?php echo esc_html__( 'Minimum days of booking','wprentals');?></label>
                    <input type="text" id="period_min_days_booking" size="40" name="period_min_days_booking" class="form-control" value="">
                </div>




                <div class="col-md-6">
                    <label for="period_checkin_change_over"><?php echo esc_html__( 'Allow only bookings starting with the check in on changeover days','wprentals');?></label>
                    <select id="period_checkin_change_over" name="period_checkin_change_over" class="select-submit2">
                        <?php 
                        foreach($week_days as $key=>$value){
                            print '   <option value="'.esc_attr($key).'">'.esc_html($value).'</option>';
                        }
                        ?>
                    </select>
                </div>

                <?php
                $ajax_nonce = wp_create_nonce( "wprentals_custom_price_nonce" );
                print'<input type="hidden" id="wprentals_custom_price" value="'.esc_html($ajax_nonce).'" />    ';
                ?>

                <button type="submit" id="set_price_dates" class="wpb_button  wpb_btn-info  wpb_regularsize   wpestate_vc_button  vc_button"><?php esc_html_e('Set price for period','wprentals');?></button>


            </div><!-- /.modal-body -->
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

我收到的反馈很简单,如下所示,尽管尽管它在主页上有效(仅出于测试目的),但在模态中不起作用。在模态内部,我得到了无效的日期,我相信这是因为当首次加载模态时,start_date_owner_book和end_date_owner_book返回为空值。

var startDate = new Date($("#start_date_owner_book").val());
var endDate = new Date($("#end_date_owner_book").val());

var timeDifference = endDate - startDate;
var differenceInDays = timeDifference / (1000*3600*24);
$("#period_min_days_booking").val(Math.floor(differenceInDays));

感谢您的帮助。温馨的问候

javascript php jquery wordpress bootstrap-modal
1个回答
0
投票

在您的两个日期选择中首先禁用select2,但看到却返回空。如果检测到select2引起问题,请除去模式组标记中的tabindex="-1"属性。

© www.soinside.com 2019 - 2024. All rights reserved.