VyA - calendario pierde las fechas, la regresa al mes actual al hacer postback
This commit is contained in:
@@ -500,6 +500,9 @@
|
||||
</div>
|
||||
<asp:HiddenField runat="server" ID="HidModClienteNombre" ClientIDMode="Static" />
|
||||
<asp:HiddenField runat="server" ID="HidModCveCliente" ClientIDMode="Static" />
|
||||
|
||||
<asp:HiddenField runat="server" ID="HidCurrentMonth" ClientIDMode="Static" Value="-1" />
|
||||
<asp:HiddenField runat="server" ID="HidCurrentYear" ClientIDMode="Static" Value="-1" />
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="JS" runat="Server">
|
||||
@@ -688,8 +691,14 @@
|
||||
var date = null;
|
||||
|
||||
function InitCalendar() {
|
||||
$(document).ready(function () {
|
||||
Calendario();
|
||||
$(document).ready(function () {
|
||||
|
||||
let mes = parseInt($('#<%=HidCurrentMonth.ClientID%>').val());
|
||||
let anio = parseInt($('#<%=HidCurrentYear.ClientID%>').val());
|
||||
|
||||
|
||||
Calendario(mes,anio);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -799,7 +808,20 @@
|
||||
updateEventOnDropResize(event);
|
||||
}
|
||||
|
||||
function Calendario() {
|
||||
function Calendario(mes = -1, anio = -1) {
|
||||
|
||||
|
||||
let fechaActual = new Date();
|
||||
if (mes === -1) {
|
||||
mes = fechaActual.getMonth() + 1;
|
||||
}
|
||||
if (anio === -1) {
|
||||
anio = fechaActual.getFullYear();
|
||||
}
|
||||
|
||||
|
||||
let mesFormateado = ('0' + mes).slice(-2);
|
||||
let fechaInicio = `${anio}-${mesFormateado}-01`;
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
@@ -807,6 +829,7 @@
|
||||
var y = date.getFullYear();
|
||||
var h = {};
|
||||
|
||||
//alert(fechaInicio);
|
||||
if ($('#calendar').width() <= 400) {
|
||||
$('#calendar').addClass("mobile");
|
||||
h = {
|
||||
@@ -826,6 +849,7 @@
|
||||
|
||||
$('#calendar').fullCalendar('destroy');
|
||||
$('#calendar').fullCalendar({
|
||||
defaultDate: fechaInicio,
|
||||
header: h,
|
||||
monthNames: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
|
||||
monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
|
||||
@@ -857,10 +881,39 @@
|
||||
}
|
||||
},
|
||||
eventDrop: eventDropped,
|
||||
eventResize: eventResized
|
||||
eventResize: eventResized,
|
||||
viewRender: function(view, element) {
|
||||
|
||||
let pointDate = view.intervalStart;
|
||||
let currentMonth = pointDate.month() + 1;
|
||||
let currentYear = pointDate.year();
|
||||
|
||||
$('#<%=HidCurrentMonth.ClientID%>').val(currentMonth);
|
||||
$('#<%=HidCurrentYear.ClientID%>').val(currentYear);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function obtenerFechaInicio(mes = -1, anio = -1) {
|
||||
let fechaActual = new Date();
|
||||
|
||||
if (mes === -1) {
|
||||
mes = fechaActual.getMonth() + 1; // getMonth() es base 0, así que se suma 1
|
||||
}
|
||||
if (anio === -1) {
|
||||
anio = fechaActual.getFullYear();
|
||||
}
|
||||
|
||||
|
||||
let mesFormateado = ('0' + mes).slice(-2);
|
||||
|
||||
|
||||
let fechaInicio = `${anio}-${mesFormateado}-01`;
|
||||
|
||||
return fechaInicio;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user