1
I’m new here Xp.
How to insert the datepicker value of an html icone into the input using javascript?
I’m using the datepicker of matelialize version 0.100.2 and Vue.js, already fixed the Bug of current versions of Google Chrome, if I put the datepicker class within the input tag works perfectly, but I need it to receive from the icon to leave the input field digitable.
<div class="col s6 m4 l4">
<div class="input-field">
<i class="material-icons datepicker prefix" style="cursor:pointer;" id="dataAdmis" ref="dataAdmis" name="dataAdmis" @click="insereValornoInput()" >date_range</i>
<input placeholder="Data de admissão *" id="dataAdmis2" v-mask="'##/##/####'" v-model="dataAdmissaoFunc" type="text" required="true" />
<span class="helper-text" data-error="" ></span>
</div>
</div>
I will make available here the code to fix the Google Chrome version bug, for those who need, or want to test.
$(document).ready(function(){
$('.datepicker').on('mousedown .datepicker', (e) => {
e.preventDefault ();
}),
$('.datepicker').on('mousedown .select-dropdown', (e) => {
e.preventDefault ();
}),
$('.datepicker').on('change select', (e) => {
$ ('select'). material_select ();
}),
$('.datepicker').pickadate({
months: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
monthsShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
weekdays: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sabádo'],
weekdaysShort: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sabádo'],
weekdaysLetter: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],
today: 'Hoje',
clear: 'Limpar',
cancel: 'Sair',
close: 'Ok',
labelMonthNext: 'Próximo mês',
labelMonthPrev: 'Mês anterior',
labelMonthSelect: 'Selecione um mês',
labelYearSelect: 'Selecione um ano',
closeOnSelect: true,
selectMonths: true,
selectYears: 65,
format: 'dd/mm/yyyy',
container: 'header',
})
})
You want to take the value of an attribute that’s on the icon and put it inside the input when the guy clicks on the icon is that? Since this attribute value of the icon you want comes dynamically from somewhere?
– hugocsl
that’s right, after clicking the icon opens a datepicker, then when selecting the date the value is set in the input field
– Jony Alan