简体   繁体   English

Datepicker仅在第一个模式中工作

[英]Datepicker is only working in the first Modal

I have a page with all the products displayed for rent and below those products i placed a visual composer popup modal. 我有一个页面,其中显示了所有要出租的产品,在这些产品下面放置了一个视觉作曲家弹出模式。 The Modal is working for every product but the problem here is there are start and end date fields in modal which i created using contact form 7 and i given id's to trigger the date-picker on select of the input fields but the date-picker is working for the first modal only. 模态适用于每种产品,但这里的问题是模态中有开始日期和结束日期字段,我使用联系表格7创建了该字段,并且我给了ID以在选择输入字段时触发日期选择器,但日期选择器却是仅适用于第一个模式。 From second modal it shows nothing and all the buttons have same classes and ids and the entire page is created using visual composer plugin. 从第二个模式开始,它什么也不显示,所有按钮都具有相同的类和ID,并且整个页面都是使用可视作曲器插件创建的。

So, how can i get date-picker for all the modals in that page. 因此,如何获取该页面中所有模态的日期选择器。

Here is Jquery code 这是jQuery代码

$( "#end_date" ).datepicker({
        beforeShow: function() {
        setTimeout(function(){
            $('.ui-datepicker').css('z-index', 99999999999999);
        }, 0);
    }});
       $( "#start_date" ).datepicker({
        beforeShow: function() {
        setTimeout(function(){
            $('.ui-datepicker').css('z-index', 99999999999999);
        }, 0);
    },
        minDate: new Date(),
        onSelect : function(selected_date){
        var selectedDate = new Date(selected_date);
        var msecsInADay = 86400000;
        var endDate = new Date(selectedDate.getTime() + msecsInADay);

        $("#end_date").datepicker("option", "minDate", endDate );
      }
    });

Thank you 谢谢

herein lies the problem - 这里存在问题-

"...From second modal it shows nothing and all the buttons have same classes and ids and the entire page is created using visual composer plugin..." “ ...从第二个模式开始,它什么也不显示,并且所有按钮都具有相同的类和ID ,并且整个页面都是使用可视作曲器插件创建的。”

it is fine to replicate the classes since you can have more than one instance of a class but each ID must be unique . 复制类是很好的,因为您可以有一个类的多个实例,但是每个ID必须唯一 If you duplicate ID's then only the first one will be actioned - as you have experienced. 如果您重复ID的操作,则只有第一个操作-如您所知。 You need to have differnt ids for the second modal. 您需要为第二个模式使用不同的ID。

You could redesign the workflow and use only one modal which would solve that issue. 您可以重新设计工作流程,并仅使用一种可以解决该问题的模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM