Copied to clipboard

Flag this post as spam?

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


  • Damien Green 72 posts 134 karma points
    Sep 04, 2014 @ 19:01
    Damien Green
    1

    Stop Save executing on button click

    Hi Guys,

    I'm currently developing a custom property editor in Umbraco 7. The problem is when I add buttons to my view and handle the click event in my controller, Umbraco automatically saves the dicument and displays the green bar at the bottom of the screen. For some operations this behaviour is fine, but I have a button that changes the current view of my editor and I don't want it to save when the button is pressed.

    Is there a way to diasable the auto save, maybe I can return something (I've tried return false) in the code attached to the button click event...?

    Many thanks,

    Damien

  • Balbir singh 9 posts 102 karma points
    Aug 17, 2016 @ 07:26
    Balbir singh
    0

    Hi Damien,

    I am also facing the same issue. Did you come across any solution ?

  • Balbir singh 9 posts 102 karma points
    Aug 17, 2016 @ 10:09
    Balbir singh
    0

    The button click seems to be causing the trouble. Nonetheless I have found out a different solution. Instead of a button click I am using a directive. In this sample i wanted to download a document on click event.

    View:

     <div ng-controller="CreateMSWordController" class="downloadDoc">Download as document</div>    
    

    Controller:

    angular.module("umbraco")
    .controller("CreateMSWordController",
    function ($scope) {
    
    });
    
    angular.module('umbraco').directive("downloadDoc", function () {
    return {
        restrict: "C",
        link: function ($scope, $element) {                                 
            $element.bind('click', function () {                
                window.location = "/utility/UtilityPage/?Id=" + $scope.Id + "&type=MSWord";
            });
        }
    }
    });
    
  • Ian 178 posts 752 karma points
    Aug 17, 2016 @ 11:34
    Ian
    106

    is your problem related to a button element taking on a submit behaviour rather than a click problem?

    check your buttons are inserted like this

    <button type="button" ...
    
  • Ben Dickman 19 posts 101 karma points
    Sep 07, 2021 @ 10:56
    Ben Dickman
    0

    Thank you! I've been struggling with this, such a simple fix in the end

  • Balbir singh 9 posts 102 karma points
    Aug 17, 2016 @ 11:50
    Balbir singh
    0

    Oh yes, It worked. Thanks Ian !!

Please Sign in or register to post replies

Write your reply to:

Draft