Copied to clipboard

Flag this post as spam?

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


  • MB 113 posts 422 karma points
    Nov 15, 2018 @ 22:10
    MB
    0

    Plug-in - cancel and/or clear unsaved changes alert

    I've created a custom backoffice plug-in that uses an html table presentation for listing rows of data.

    To make it a bit more functional, I added a basic filter, where there is a text-box with a ng-change and ng-model, that updates the filter:model of the ng-repeat on the table rows. Very basic, but works well enough to be useful.

    However, when I go to leave the node using the plug-in, Umbraco insists on nagging me about having unsaved changes, even though the only changes are to the filter, and not to the tabular content itself... which is read-only.

    Anyone got an idea on what triggers this status check, and how I can cancel it to stop the unnecessary and alarming alert ?

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Nov 16, 2018 @ 10:20
    Dave Woestenborghs
    0

    Hi MB,

    Can you show us some code. Your are problably setting the filter on the model...and so you are changing your model. This triggers umbraco to see it as dirty and will show the dialog.

    Dave

  • MB 113 posts 422 karma points
    Nov 16, 2018 @ 21:47
    MB
    0

    Specifying a client-side filter from a textbox using ng-change="myHandler()" which requires that you specify ng-model="myFilterVar"

    Then use as: tr ng-repeat="item in items | filter:myFilterVar"

    I appreciate Umbraco has decided that a change to myFilterVar means the app is "dirty" but I know that's spurious, and just want to ignore or clear the dirty state.

    I've seen this problem with a number of other plugins (not mine) where you'll use them to view/read info, only to have Umbraco throw an unsaved data alert when you exit, despite there being nothing you can change or save.

  • MB 113 posts 422 karma points
    Nov 23, 2018 @ 10:54
    MB
    100

    So, I found the answer to my own question, and it's documented... I just needed to understand where and what to look for.

    There is an umbraco directive available "noDirtyCheck" and once I added it to my filter input it no longer flagged the model as dirty, and so stopped throwing an unsaved data alert on exit.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Nov 23, 2018 @ 11:05
    Dave Woestenborghs
    0

    Yep...I actually use that myself....should have remembered it.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft