I'm working on a website currently created in AngularJS. I do NOT have access to the backend where the code exists. I need to develop a script to make changes to that page using CSS, Javascript, or JQuery. One of those changes involves creating a new element. Once the user clicks on that element(mobile users will use touchstart not click) it will need to trigger a click event on an existing element on the page.
$('.DatePicker').on('click touchstart touch',function(){
//on click of element, sim click on the bau date to pop open datepicker
console.log('datepicker clicked');
$('input#dateMobile').trigger('touchstart');
});
This is what I currently have. I can get the console log to appear but the trigger on the element will not work regardless if I use click, touch, touchstart, touchend.
That is the current html of the element i'm trying to trigger click on :
<input type="date" id="dateMobile" class="payment-date__input ng-valid-min ng-valid-max ng-valid-v-date ng-valid-v-date-min ng-valid-v-date-max ng-valid-v-date-format ng-dirty ng-valid-date ng-valid ng-valid-required ng-touched" name="dateMobile" friendly-date="" validate-date-range=""
ng-if="isMobile.any" min="2017-02-03" max="2017-04-04"
ng-model="dateModelMobile"
ng-blur="updateDate('dateModelMobile')"
ng-change="updateDate('dateModelMobile')" required="" aria-required="false" aria-invalid="false">
<button ng-click="orderDate()">order</button>
and in scope$scope.orderDate = function(){... }
<input type="date" id="dateMobile" class="payment-date__input ng-valid-min ng-valid-max ng-valid-v-date ng-valid-v-date-min ng-valid-v-date-max ng-valid-v-date-format ng-dirty ng-valid-date ng-valid ng-valid-required ng-touched" name="dateMobile" friendly-date="" validate-date-range="" ng-if="isMobile.any" min="2017-02-03" max="2017-04-04" ng-model="dateModelMobile" ng-blur="updateDate('dateModelMobile')" ng-change="updateDate('dateModelMobile')" required="" aria-required="false" aria-invalid="false">
that is the current html of the element i'm trying to trigger click onupdateDate()
. you can add your code in this function in the controller