Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
hello ... I have an events calendar using cms:calendar which I have set up with the help of @kk http://www.couchcms.com/forum/viewtopic.php?f=2&t=9243

I have a question about the use of querystrings and reloading of the page ...

The url is index.php, when the link to the next month is clicked on the calendar the url becomes index.php?cal=2015-12-01 and the next month is shown on the calendar.

However, this causes the page to reload and a jump to top of page - leaving the calendar at the bottom of the screen or out of view - depending on screen size.

I have tried to minimise this effect by putting in an anchor by the calendar <a name="calendar"></a> and adding #calendar to the querystring - but there is still a jump and an unnecessary reload of all the other page contents. (Another thing is that the back button will go back through all those calendar months viewed as well .... )

Just wondering if there is a way to override this behaviour and allow the calendar to behave more like an independent widget within the page - scroll through months without reloading the whole page each time?

Any suggestions? Thanks!
Any suggestions?
I think you should use AJAX to load the page in background and then replace the calendar with the fetched contents.

You can use cms:is_ajax (viewtopic.php?p=18342#p18342) in the calendar template to figure out if it is being accessed via AJAX and return only the relevant markup
Code: Select all
<cms:if "<cms:is_ajax />">
    ..
</cms:if>

Alternatively you can simply return the entire page and then ask JQuery to cherry-pick only the calendar part of it to make the replacement - https://api.jquery.com/load/#loading-page-fragments

Bottom-line is that the solution has more to do with front-end scripting than with Couch itself.

Hope it helps.
2 posts Page 1 of 1