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

Feat: Client-side hooks - replace window.trigger #9679

Merged
merged 4 commits into from
Aug 13, 2021

Conversation

Antosik
Copy link
Contributor

@Antosik Antosik commented Jul 29, 2021

Done:

  • All $(window).trigger entries were replaced by hooks.fire

@julianlam
Copy link
Member

Oh! Wow, okay 😁

Do you want to work for NodeBB?

@barisusakli
Copy link
Member

Replacing
$(window).trigger with

require(['hooks'], function (hooks) {
   hooks.trigger()
});

Sometimes causes issues when the load order is important. So it's best to require hooks at the top of the file.

public/src/ajaxify.js Outdated Show resolved Hide resolved
@psychobunny
Copy link
Contributor

nice 👍 I think this require can be removed?

NodeBB/public/src/app.js

Lines 63 to 71 in 42c164f

require(['hooks'], function (hooks) {
hooks.on('action:ajaxify.end', function () {
document.body.removeEventListener('click', earlyClick);
earlyQueue.forEach(function (el) {
el.click();
});
earlyQueue = [];
});
});

@Antosik
Copy link
Contributor Author

Antosik commented Jul 29, 2021

I think this require can be removed? (NodeBB/public/src/app.js#63-71)

I tried to remove it but it causes an error. app.handleEarlyClicks is called right after it was defined and hooks module isn't ready yet.

@Antosik Antosik requested a review from barisusakli July 29, 2021 16:57
@barisusakli barisusakli added this to the 1.18.0 milestone Aug 13, 2021
@barisusakli barisusakli merged commit 342503e into NodeBB:master Aug 13, 2021
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.

None yet

4 participants