atatanasov / gijgo

Gijgo - Free Javascript Controls
http://gijgo.com
MIT License
475 stars 188 forks source link

DatePicker - Infinite event loop (change, close ...) once value set #472

Open exstyle opened 5 years ago

exstyle commented 5 years ago

EDIT : Infinite event, when value is set (the bug occurs also with only one datepicker)). The event is also fired as soon as we click, so before the change (once the value has been set).

I believe it's the same bug.

Was working ok before i upgrade to 1.9.11 (can't remember which version i had before).

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Example</title>
  <script src="/Areas/Development/dist/libraries/jquery/jquery.js"></script>
  <script src="/Areas/Development/dist/modular/js/core.js" type="text/javascript"></script>
  <link href="/Areas/Development/dist/modular/css/core.css" rel="stylesheet" type="text/css">
  <link href="/Areas/Development/dist/modular/css/datepicker.css" rel="stylesheet" type="text/css">
  <script src="/Areas/Development/dist/modular/js/datepicker.js"></script>
</head>
<body style="padding: 8px;">
 <input id="datepicker1" width="312" />
 <script>
     $('#datepicker1').datepicker({
         change: function (e) {
             alert('Change is fired');
         }
     });
 </script>
</body>
</html>
kreilinger commented 5 years ago

I have the same problem, but it only happens when i select multiple inputs like $('#input1, #input2'). Changing this to $('#input1').datepicker(); and $('#input2').datepicker(); works for me

Se7enShawn commented 5 years ago

I can confirm this bug on 1.9.13, using the test: select: function (e, type) { alert('Select from type of "' + type + '" is fired'); }

I obtain infinite alert. Also with single input: $('#input').datepicker()

Sonic1305 commented 4 years ago

Still present, will this ever be fixed?

Joicekurups commented 3 years ago

@Sonic1305 @exstyle I have found a solution to this problem

$('#deliveryDate').datepicker({ format: 'dd/mm/yyyy', }); var lastValue = null; //or last value $("#deliveryDate").on("change", function(e) { if(lastValue !== e.target.value){ alert("hi") console.log(e.target.value) lastValue = e.target.value; }

Try it