Forum Discussion
MarioZagreb
Mar 22, 2024Brass Contributor
jQuery datepicker on site page
Hello,
I have 2 site pages (page1.aspx and page2.aspx). Both have different customized (with SPfx) web parts on them and both have jQuery UI datepickers. And they work if you open them directly through URL (or simply refresh them).
The problem is this scenario:
1. You open page1.aspx - everything works.
2. Then you click page2.aspx through Quick Launch - jQuery UI doesn't work.
If you refresh that page then everything works again.
It seems that page isn't refreshed when accessing through quick launch links. I jQuery UI then referenced twice?
This is the error in Console:
Uncaught (in promise) Error: Not ready to attach AnnotationsListeners
How can I refresh page EVERY TIME you click a link in quick launch?
1 Reply
- MarioZagrebBrass ContributorOk, I found the solution in this thread:
https://techcommunity.microsoft.com/t5/sharepoint/sharepoint-online-webparts-not-loading-correctly-until-page/m-p/2908602
protected async onInit(): Promise<void> {
await super.onInit();
navterm = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1);
((history) => {
var pushState = history.pushState;
history.pushState = (state, key, path) => {
pushState.apply(history, [state, key, path]);
this._onUrlChange();
};
})(window.history);
window.addEventListener('popstate', function (e) {
// Currently browsing by the browser history buttons ( back / forward )
// doesn't cause any effect on a sp conditionally loaded page.
// this._onUrlChange();
});