PDA

View Full Version : Calendar's listener triggers at Page Loading without being called.



jsamhv
Jul 13, 2016, 3:18 AM
Hello,

I'm working with a calendar panel, I've put a Listener like this:




<ext:CalendarPanel runat="server" ID="calendario" Header="false"
CellCls="align:left;" ShowWeekView="false" ShowDayView="false"
ShowTodayText="false" AnchorHorizontal="100%">

<ResponsiveConfig>
<ext:ResponsiveRule Rule="wide">
<Config>
<ext:CalendarPanel runat="server" Height="700px" AnchorHorizontal="100%">
<Listeners>
<Resize Handler="App.direct.IluminarCalendario();"></Resize>
</Listeners>
</ext:CalendarPanel>
</Config>
</ext:ResponsiveRule>
<ext:ResponsiveRule Rule="tall">
<Config>
<ext:CalendarPanel runat="server" Height="400px" AnchorHorizontal="100%">
<Listeners>
<Resize Handler="App.direct.IluminarCalendario();"></Resize>
</Listeners>
</ext:CalendarPanel>
</Config>
</ext:ResponsiveRule>
</ResponsiveConfig>

<MonthView
runat="server"
ShowHeader="true"
ShowWeekLinks="false"
ShowWeekNumbers="false"
EnableFx="true"
/>

<DirectEvents>
<DayClick OnEvent="calendario_StateChanged" Before="extraParams.date = dt;" />
</DirectEvents>
<Listeners>
<DateChange Handler="App.direct.IluminarCalendario();"></DateChange>
</Listeners>

</ext:CalendarPanel>



I use the DateChange Listener's Handler: "App.direct.IluminarCalendario();" to call a Direct Method in order to highlight some days in the calendar, however, this handler is triggered at the Page loading when I expected it to work when the calendar's date has changed, I'd like to know why this happens, how is it supposed to work?

Thank you in advance.

fabricio.murta
Jul 13, 2016, 9:16 PM
Hello @jsamhv! Welcome to Ext.NET forums!

Any panel's resize event can be triggered during page load, for instance, while adequating the page layout, which imposes a resize to the panel. That's just to say one cause that can trigger this during page load.

You may want to add the event only after the page is loaded, or 'signal' the page as loaded and do not call the listener until then.

For example, having a script tag containing:



var pageIsLoaded = false;
Ext.onReady(function() { pageIsLoaded = true; });


And then in your listener:



if (pageIsLoaded) App.direct.IluminarCalendario();


This could be one solution for your problem.