2017-09-30 15 views
5

मैंने Jquery UI का उपयोग करके कस्टम दिनांक सीमा पिकर बनाया है।JQuery UI डेटपिकर में Google क्रोम समस्या

यह अन्य ब्राउज़र में पूरी तरह से काम करता है लेकिन Google में यह ठीक से काम नहीं करता है।

स्नैप के नीचे देखें।

लाल दौर खाली होना चाहिए, लेकिन यह कुछ पाठ हो जाता है, शायद लूप के कारण, लेकिन मैं इसे समझ नहीं सकता।

enter image description here

मेरे js कोड।

$(function() { 

     from = $("#from").datepicker({ 
      defaultDate: "+1w", 
      numberOfMonths: 2, 
      minDate: +7, //THIS IS FIRST PLACE 
      autoclose: false, 
      beforeShow: function (input, inst) { 
       $("#ui-datepicker-div td").off(); 

       $(document).on("mouseenter", "#ui-datepicker-div td", function (e) { 
        $(this).parent().addClass("finalRow"); 
        $(".finalRow").parents('.ui-datepicker-group-last').parent().find('.ui-datepicker-group-first').find('tr').last().addClass("finalRowRangeOtherTable"); 
        $(".finalRow").prevAll().find("td:not(.ui-datepicker-unselectable)").removeClass("highlight"); 
        $(this).prevAll("td:not(.ui-datepicker-unselectable)").removeClass("highlight"); 
       }); 
      }, 
      beforeShowDay: function (date) { 
       var d = date.getTime(); 
       if ($("#to").datepicker("getDate") && d == $("#to").datepicker("getDate").getTime()) { 
        return [true, 'ui-red', '']; 
       } 

       if ($("#from").datepicker("getDate") && $("#to").datepicker("getDate") && d < $("#to").datepicker("getDate").getTime() && d > $("#from").datepicker("getDate").getTime()) { 
        return [true, 'ui-state-highlight', '']; 
       } else { 
        return [true, '']; 
       } 
      }, 
      onClose: function (selectedDate) { 
       var selectedDate = $("#from").datepicker("getDate"); 
       if (selectedDate != null) { 
        $('#to').datepicker('option', 'minDate', selectedDate).datepicker('refresh'); //THIS IS SECOND PLACE 
       } 
       $("#from").datepicker("option", "dateFormat", "d MM, yy"); 
       $("#to").datepicker("show"); 
      } 
     }) 

     to = $("#to").datepicker({ 
      defaultDate: "+1w", 
      numberOfMonths: 2, 
      autoclose: false, 
      beforeShow: function (input, inst) { 
       $("#ui-datepicker-div td").off(); 

       $(document).on("mouseenter", "#ui-datepicker-div td", function (e) { 

        $(this).parent().addClass("finalRow"); 
        $(".finalRow").parents('.ui-datepicker-group-last').parent().find('.ui-datepicker-group-first').find('tr').last().addClass("finalRowRangeOtherTable"); 
        $(".finalRowRangeOtherTable").find("td:not(.ui-datepicker-unselectable)").addClass("highlight"); 
        $(".finalRowRangeOtherTable").prevAll().find("td:not(.ui-datepicker-unselectable)").addClass("highlight"); 

        $(".finalRow").prevAll().find("td:not(.ui-datepicker-unselectable)").addClass("highlight"); 
        $(this).prevAll("td:not(.ui-datepicker-unselectable)").addClass("highlight"); 
       }); 

       $(document).on("mouseleave", "#ui-datepicker-div td", function (e) { 

        $(this).parent().removeClass("finalRow"); 
        $("#ui-datepicker-div td").removeClass("highlight"); 

        $(".finalRowRange").removeClass("finalRowRange").find('.highlight').removeClass("highlight"); 
        $(".finalRowRangeOtherTable").removeClass("finalRowRangeOtherTable").find('.highlight').removeClass("highlight"); 

       }); 
      }, 
      beforeShowDay: function (date) { 
       var d = date.getTime(); 
       if ($("#from").datepicker("getDate") && d == $("#from").datepicker("getDate").getTime()) { 
        return [true, 'ui-red', '']; 
       } 
       if ($("#from").datepicker("getDate") && $("#to").datepicker("getDate") && d < $("#to").datepicker("getDate").getTime() && d > $("#from").datepicker("getDate").getTime()) { 
        return [true, 'ui-state-highlight', '']; 
       } else { 
        return [true, '']; 
       } 
      } 
     }) 
     .on("change", function() { 
      from.datepicker("option", "maxDate", getDate(this)); 
      $("#to").datepicker("option", "dateFormat", "d MM, yy"); 
     }); 
    }); 

मैं इसे सीएसएस के साथ मुद्दा है क्योंकि यह IE में भी अन्य ब्राउज़र पर पूरी तरह से काम करता है नहीं लगता।

मैंने यह भी पाया है कि यह तब होता है जब और जब मैं datepicker में से किसी को minDate असाइन करते हैं, अगर मैं datepicker ठीक काम करता है कि लाइनों को हटाने, जे एस कोड में मेरी टिप्पणी देखने के लिए, लेकिन जैसा कि मैंने कस्टम श्रेणी datepicker उपयोग कर रहा हूँ, मुझे उन लाइनों की आवश्यकता होगी, क्या मैं किसी अन्य विकल्प का उपयोग कर सकता हूं?

यहां बेवकूफ है। LINK

  1. Google Chrome में ओपन बेला
  2. आरंभ तिथि के रूप में चुनें 10 अक्टू
  3. समाप्ति तिथि के रूप में चुनें 23 अक्टू
  4. अब, ओपन datepicker एक के बाद एक के दोनों है, और पर होवर दिनांकों और जैसा कि मैंने स्नैप (ऊपर) में जोड़ा है, आपको अतिरिक्त तिथि दिखाई देगी ..
  5. मैं लाइव लिंक के सीएसएस को ओवरराइट नहीं कर सका, इसलिए डिज़ाइन थोड़ा सा दिखता है ..
+1

क्रोम अद्यतन से पहले क्रोम 61 के साथ एक बग की तरह लगता है किया गया है प्रतीत होता है, यह ठीक काम किया। उसके बाद, मैं ओपी की समस्या देख रहा हूं। – Zyren

उत्तर

4

मुझे आपकी अपनी समस्या थी।

क्रोम यूनिकोड वर्ण & # xa0 को सही ढंग से हल करने के लिए प्रतीत नहीं होता है।

तो अपने jquery-ui * .js में & # xa0 खोजें और "" के साथ प्रतिस्थापित करें।

मैंने केवल चरित्र के निर्दिष्ट मौके को प्रतिस्थापित किया (उस फ़ाइल में "ui-datepicker-other-month" खोजें) और यह काम करता है।

+0

यह काम कर रहा है, धन्यवाद! लेकिन मुझे अभी भी यह समझ में नहीं आता है, यह वास्तव में क्या "& # xa0" करता है? और क्या होगा यदि मैं इसे पूरी जेएस फ़ाइल से हटा दूं? – Bharat

+0

"& # xa0" गैर-ब्रेकिंग स्पेस का यूनिकोड है। मुझे लगता है कि जब आप पूरी जेएस फ़ाइल से हटाते हैं तो आपको सावधान रहना चाहिए। आपको कोड के टुकड़े को पढ़ना चाहिए जहां चरित्र का उपयोग यह जानने के लिए किया जाता है कि इसका उपयोग क्यों किया जाता है। किसी भी अपवाद को रोकने के लिए इस प्रकार का दृष्टिकोण उपयोगी है। –

+2

हालांकि यह उत्तर तकनीकी रूप से समस्या को हल करता है, मुझे पूरा यकीन है कि इसे क्रोम के अंत में पैच किया जाना चाहिए। मैं jquery ui डेटपिकर कोड को अपडेट करने की अनुशंसा नहीं करता जबतक कि जब तक क्रोम इसे पैच नहीं कर लेता तब तक आपको समस्या को ठीक करने के लिए बिल्कुल आवश्यकता नहीं थी। – Zyren

4

Zyren द्वारा बताया गया है कि यह एक बग क्रोम 61 में शुरू की गई यह क्रोम में तय किया गया है 62.

संबंधित मुद्दे