Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Updated the method to call init() using newer XWiki API #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wthrajat
Copy link
Member

@wthrajat wthrajat commented Aug 3, 2023

This PR doesn't change anything except for using a shorter method to first check for DOM loaded and then for DOM updated.
Idea credits: @mflorea

This calls init:

  • first when DOM is ready: $(init)
  • then each time DOM is updated: .on('xwiki:dom:updated', init);

Similar usecase: https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-tree/xwiki-platform-tree-war/src/main/webapp/resources/uicomponents/widgets/tree.js#L32

See: https://api.jquery.com/jquery/#jQuery3

Copy link
Member

@9inpachi 9inpachi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. I have one minor comment.

@@ -459,13 +459,9 @@ require(['jquery', 'leaflet', 'leaflet-commons', 'leaflet-indoor', 'bootstrap'],
$('.map-search-filter').removeClass('open');
leafletCommons.updateURLWithMapState();
});

$(init).on('xwiki:dom:updated', init);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement is inside the init function. It won't work because the init function will never be called and even if it's called like this, it will result in an infinite recursion.

You can move this statement outside the scope of the init function and it should work just fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@9inpachi is right. This line needs to be moved below, outside the init function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants