DatePicker with AspNetCore Typescript


#1

Hi all,

i’m trying to use a datepicker with aurelia typescript aspnet.
I’m not able to take the value of the date. I tryied 3-4 differents methods but it’doesn’t seems working.

The Code:

<div class="form-group">
   <div class="col-sm-2">
      <label class="control-label">Date</label>
   </div>
   <div class="col-sm-10">
      <div class="input-group">
         <div class="input-group-addon">
            <i class="fa fa-calendar"></i>
         </div>
         <input type="text" id="datepicker" model.bind="myDateValue" placeholder="mm/dd/yyyy" class="form-control" data-inputmask="'alias': 'dd/mm/yyyy'" data-mask="">
      </div>
   </div>
</div>

for the class i use a simple variable:

myDateValue : Date;

I’m trying to take the value with the “change.delegate” event… with a input with a “type=‘date’”:

<input id="datepicker"
   value.bind="test" type="date" class="form-control" date-format="{0:yyyy-MM-dd}"  min="2018-01-01" max="2018-12-31"  >
</div>

but this never enter in the method.

someone could help me?

Thanks,
Andrea


#2

It depends on the datepicker you’re using.


#3

I have tryed a lot of different types.
If you want paste a your small and simple tutorial … it is welcome :smiley:


#4

I’ve run into this with a datepicker plugin/library. Not sure if it’s the same issue but for me the issue with the change.delegate not firing was due to how the plugin was injecting the updated value to the input. In my case they were using jquery’s $('input').val('new value') which does not trigger a changed event. I had to add a hook in to fire a trigger for the change event myself so that whenever the datepicker plugin updated the value, it would manually trigger the change event $('input').trigger('change'). The same applies for when you are changing the binding value using aurelia.

You can see this thread for more info: Missing change event when changing model on input value.bind