Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kim Løwert 130 posts 116 karma points
    Dec 06, 2010 @ 08:11
    Kim Løwert
    0

    Javascript method/event that I can register script to be executed on save

    Hi Everybody

    Do any of you guys know if there is a method that I can register script to execute on saving a document?

    In v3 there was a method called addSaveHandler(handler) in editContent.aspx that could be called to register clientscripts to be executed on save. Do any of you know if a similar method exists in v4.5.2?

    Thanks a lot in advance :)

    Kim

  • Kim Løwert 130 posts 116 karma points
    Dec 08, 2010 @ 13:47
    Kim Løwert
    0

    Hi everybody,

    After a little look around I found that the addSaveHandler(handler) js method was still present, but has been moved to the bottom of the editContent.aspx page. Therefore calling the method from a control/data type resulted in an error that described that the method did not exist. After wrapping the call in the jQuery(document).ready(function() { } ); it now works.

     

    jQuery(document).ready(function (){ addSaveHandler(save handler method here); });

    Hope this helps you if you run into the same issue :)
    Kim

     

  • greengiant83 88 posts 109 karma points
    Mar 18, 2011 @ 16:42
    greengiant83
    0

    I am trying to do the same thing, but while I see that addSaveHandler is defined, my handler never seems to get called.  I am adding it like this.  Any idea why this doesnt pop an alert after cliking the save or publish button?

    $(function()
        {
            addSaveHandler(function() { alert("saving??"); });
        });

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Mar 22, 2012 @ 10:45
    Steen Tøttrup
    0

    Did anybody ever find a solution for this?

    I'm working on a complex datatype for Umbraco 4 (4.7.1.1), and need to store some data into a hidden field before the editor page is submitted. So what I need is to get informed when "save" or "save and publish" are clicked.

    Any ideas ?

     

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Mar 22, 2012 @ 10:53
    Steen Tøttrup
    0

    Okay, found out with a little more digging.

    No idea why, but when "save" is clicked, the save handlers are iterated and executed using eval, so this seems to solve everything:

    $(function()
       
    {
            addSaveHandler
    ("alert(\"saving??\")");
       
    });
  • Comment author was deleted

    Dec 10, 2012 @ 22:38

    Agree with Steen, this doesn't work as described by Kim.

    As a workaround, I'm adding event handlers to the actual save icons :(

      //add onSave handlers
    $(".tabpagecontainer .editorIcon[title=Save], .tabpagecontainer .editorIcon[title='Save and publish']").click(function(){
    alert('saving');
    });

     

Please Sign in or register to post replies

Write your reply to:

Draft