I am using a combination of JQuery, Modernizr, and Angular to achieve a custom Datepicker solution for a table generated via ng-repeat. The solution works if I hard-code the Angular directive of "datepicker" into the HTML.
So, for example, within my table using ng-repeat"revenue in runway.revenues" this works:
<td>
<input type="date" class="form-control" ng-model="revenue.date" placeholder="YYYY-MM-DD" datepicker required/>
</td>
But I would like for this to only be put into place when the user is in a browser that requires it. So, with this in mind, I have deleted datepicker from the above HTML, and written this in JS:
$(function() {
var nativeDateInputIsSupported = Modernizr.inputtypes.date;
if (!nativeDateInputIsSupported) {
$('input[type="date"]').prop("datepicker", true)
}
});
However, when I land on the page in Firefox, it does not appear to work.
Further, if I try to debug by doing something like console.log($('input[type="date"]').prop("class")) the value returned will be undefined (which should be form-control).
Any tips would be greatly appreciated!
console.log($('input[type="date"]').attr("class"))orconsole.log($('input[type="date"]').prop("className")).attr()to set attribute at HTMLconsole.log($('input[type="date"]').length)(it will get the number of matched element exist in DOM, if there's more than 1,.attr()or.prop()won't work), if result is 1, then tryconsole.log($('input[type="date"]').prop('outerHTML'))(maybe really there's no class attribute)console.log($('input[type="date"]').length), the returned result is 0. This occurs if I include it within a$(document).ready(...as well