2015-10-06 108 views
5

我想打開jquery對話框,但它不打開我也使用jquery datepicker。當我刪除日期選擇器的兩個jQuery腳本時,對話將打開,否則它不會以任何方式工作。任何人建議我任何jQuery腳本的對話框,可以與這些datepicker腳本工作。jQuery對話框不能使用Datepicker

的javascript日期選擇器代碼:

<script src="./jquery.js"></script> 
<script src="./jquery.datetimepicker.js"></script> 
<script>/* 
window.onerror = function(errorMsg) { 
    $('#console').html($('#console').html()+'<br>'+errorMsg) 
}*/ 
$('#datetimepicker').datetimepicker({ 
dayOfWeekStart : 1, 
lang:'en', 
disabledDates:['1986/01/08','1986/01/09','1986/01/10'], 
startDate: '1986/01/05' 
}); 
$('#datetimepicker').datetimepicker({value:'2015/04/15 05:03',step:10}); 

$('.some_class').datetimepicker(); 

$('#default_datetimepicker').datetimepicker({ 
    formatTime:'H:i', 
    formatDate:'d.m.Y', 
    //defaultDate:'8.12.1986', // it's my birthday 
    defaultDate:'+03.01.1970', // it's my birthday 
    defaultTime:'10:00', 
    timepickerScrollbar:false 
}); 

$('#datetimepicker10').datetimepicker({ 
    step:5, 
    inline:true 
}); 
$('.datetimepicker_mask').datetimepicker({ 
    mask:'9999/19/39 29:59' 
}); 

$('#datetimepicker1').datetimepicker({ 
    datepicker:false, 
    format:'H:i', 
    step:5 
}); 
$('#datetimepicker2').datetimepicker({ 
    yearOffset:222, 
    lang:'ch', 
    timepicker:false, 
    format:'d/m/Y', 
    formatDate:'Y/m/d', 
    minDate:'-1970/01/02', // yesterday is minimum date 
    maxDate:'+1970/01/02' // and tommorow is maximum date calendar 
}); 
$('#datetimepicker3').datetimepicker({ 
    inline:true 
}); 
$('#datetimepicker4').datetimepicker(); 
$('#open').click(function(){ 
    $('#datetimepicker4').datetimepicker('show'); 
}); 
$('#close').click(function(){ 
    $('#datetimepicker4').datetimepicker('hide'); 
}); 
$('#reset').click(function(){ 
    $('#datetimepicker4').datetimepicker('reset'); 
}); 
$('#datetimepicker5').datetimepicker({ 
    datepicker:false, 
    allowTimes:['12:00','13:00','15:00','17:00','17:05','17:20','19:00','20:00'], 
    step:5 
}); 
$('#datetimepicker6').datetimepicker(); 
$('#destroy').click(function(){ 
    if($('#datetimepicker6').data('xdsoft_datetimepicker')){ 
     $('#datetimepicker6').datetimepicker('destroy'); 
     this.value = 'create'; 
    }else{ 
     $('#datetimepicker6').datetimepicker(); 
     this.value = 'destroy'; 
    } 
}); 
var logic = function(currentDateTime){ 
    if (currentDateTime && currentDateTime.getDay() == 6){ 
     this.setOptions({ 
      minTime:'11:00' 
     }); 
    }else 
     this.setOptions({ 
      minTime:'8:00' 
     }); 
}; 
$('#datetimepicker7').datetimepicker({ 
    onChangeDateTime:logic, 
    onShow:logic 
}); 
$('#datetimepicker8').datetimepicker({ 
    onGenerate:function(ct){ 
     $(this).find('.xdsoft_date') 
      .toggleClass('xdsoft_disabled'); 
    }, 
    minDate:'-1970/01/2', 
    maxDate:'+1970/01/2', 
    timepicker:false 
}); 
$('#datetimepicker9').datetimepicker({ 
    onGenerate:function(ct){ 
     $(this).find('.xdsoft_date.xdsoft_weekend') 
      .addClass('xdsoft_disabled'); 
    }, 
    weekends:['01.01.2014','02.01.2014','03.01.2014','04.01.2014','05.01.2014','06.01.2014'], 
    timepicker:false 
}); 
var dateToDisable = new Date(); 
    dateToDisable.setDate(dateToDisable.getDate() + 2); 
$('#datetimepicker11').datetimepicker({ 
    beforeShowDay: function(date) { 
     if (date.getMonth() == dateToDisable.getMonth() && date.getDate() == dateToDisable.getDate()) { 
      return [false, ""] 
     } 

     return [true, ""]; 
    } 
}); 
$('#datetimepicker12').datetimepicker({ 
    beforeShowDay: function(date) { 
     if (date.getMonth() == dateToDisable.getMonth() && date.getDate() == dateToDisable.getDate()) { 
      return [true, "custom-date-style"]; 
     } 

     return [true, ""]; 
    } 
}); 
$('#datetimepicker_dark').datetimepicker({theme:'dark'}) 


</script> 

jQuery的對話框:

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> 
    <script src="//code.jquery.com/jquery-1.10.2.js"></script> 
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
    <script type="text/javascript"> 
      $(document).ready(function() { 

       $('#wrapper').dialog({ 
        autoOpen: false, 
        title: 'Basic Dialog' 
       }); 
       $('#opener').click(function() { 
        $('#wrapper').dialog('open'); 
//     return false; 
       }); 
      }); 
     </script> 


<button id="opener">Open the dialog</button> 
<div id="wrapper"> 
    <p>Some txt goes here</p> 
</div> 
+1

你已經包含jquery js兩次'jquery.js'和'code.jquery.com/jquery-1.10.2.js'。請在頂部添加其中一個,看看你得到了什麼。 –

+1

是的,你是對的我已經刪除了jquery.js並且在頂部包含了code.jquery.com/jquery-1.10.2.js並且它可以工作。非常感謝您的評論作爲答案,以便我接受它。 – nagi

回答

0

您已經包括jQuery的JS兩次jquery.jscode.jquery.com/jquery-1.10.2.js。請在頂部添加其中一個,看看你得到了什麼。