Support

Home Forums Event Espresso Premium Overriding Javascript Function

Overriding Javascript Function

Posted: June 9, 2020 at 2:58 pm

Viewing 2 reply threads


joephg-MOH

June 9, 2020 at 2:58 pm

Hi,
What is the best way to override a javascript function. Specifically this line: https://github.com/eventespresso/event-espresso-core/blob/dce71d47e8158513b989cd34fb7a0c1ce86e6f09/core/templates/global_assets/scripts/espresso_core.js#L59

Due to the way we setup our sites all modals must be inside a wrapper that we setup, so I just need to change the div it appends to and keep it future-proof.

Thanks,
Joe


Tony

  • Support Staff

June 10, 2020 at 4:17 am

Hi Joe,

You can use wp_add_inline_script() to override the function.

Something like this:

https://gist.github.com/Pebblo/49c55ce8f85ec01fb58a9edcb03176e2

(That just adds a console.log call to that method but you can obviously change whatever you prefer)

Add that to a custom functions plugin on the site, we have some documentation on creating one here:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/


joephg-MOH

June 10, 2020 at 7:04 am

Thank you. Good to close this if needed.

Viewing 2 reply threads

The support post ‘Overriding Javascript Function’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso