Sign in to follow this  
theo

Intercept Page->Save from Javascript?

Recommended Posts

Hello

Is there a way for a module to get an event via JS/JQuery when (actually before) a Page is saved?

For example for showing an alert like "There are unsaved changes" or saving these changes automatically (Ajax)?

Thank you.

Share this post


Link to post
Share on other sites

@dragan Thanks, but this ist PHP, right? I need JS.

But I think this seems to work afaics now.

$("#submit_save").bind("click", function() { alert('beforesave'); return true; });

Thank you.

Share this post


Link to post
Share on other sites

Yes, that's PHP, but you can also inject JS in a hook with

$js = "<script>your script here...</script>";
$event->return = str_replace("</body>", "{$js}</body>", $event->return);

 

  • Like 1

Share this post


Link to post
Share on other sites

Hey there, @theo! Just wanted to notify you that I'm moving this topic to the "Module/Plugin Development" subforum.

The "Modules/Plugins" forum area is where support boards for existing modules live, while all module development related topics belong to the "Module/Plugin Development" subforum. Thanks, and sorry for the disturbance 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.