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

Add typeChange event to Craft.EntryTypeSwitcher #3067

Merged
merged 4 commits into from
Jul 4, 2018
Merged

Add typeChange event to Craft.EntryTypeSwitcher #3067

merged 4 commits into from
Jul 4, 2018

Conversation

joshangell
Copy link
Contributor

This allows plugins to listen to the event and do things when the entry type is switched e.g. Garnish.on(Craft.EntryTypeSwitcher, 'typeChange', function() {…});

I have tested this locally by running the grunt build and it works well.

This allows plugins to listen to the event and do things when the entry type is switched e.g. `Garnish.on(Craft.EntryTypeSwitcher, 'typeChange', function() {…});`
@narration-sd
Copy link
Contributor

narration-sd commented Jul 4, 2018

Just made me curious by how you described this, Josh.

I'm not aware of a plugin system for Garnish, save for generic means as this: https://craftcms.stackexchange.com/questions/1386/can-garnish-be-extended-to-allow-plugins-to-use-custom-keyboard-shortcuts

So if not, I guess you;'re talking about a Craft plugin 'listening to an event', and then I wonder why not pick up the change in Craft itself -- pr'ing an event if there isn't an appropriate one there?

Could be I will learn something :)

@brandonkelly
Copy link
Member

@narration-sd Garnish.on() is a way to add class-level events to classes that extend Garnish.Base (e.g. Craft.EntryTypeSwitcher). So you don’t have to worry about finding the actual instance of the class. Similar to Yii’s Event::on().

@brandonkelly brandonkelly merged commit 1503df4 into craftcms:develop Jul 4, 2018
@joshangell
Copy link
Contributor Author

Thanks @brandonkelly!

@khalwat
Copy link
Contributor

khalwat commented Sep 27, 2020

@joshangell I could kiss you for this. It's exactly what I need to fix a weird edge-case issue. Thank you!

@joshangell
Copy link
Contributor Author

@khalwat you're welcome, just make sure you wear a mask ...

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.

4 participants