SilverStripe: Stay on page leave page are you sure

From FVue
Jump to: navigation, search

Problem

I've added a checkbox for GridField records so that one can perform mass-actions. However, if a checkbox is checked and an action-button is clicked, this messagebox appears:

Are you sure?
This page is asking you to confirm that you want to leave - data you have entered may not be saved.
Stay on Page - Leave Page

Environment

  • SilverStripe-3.0

Solution

Add "no-change-track" as CSS-class to the checkbox input elements.

I found about this from comments in the SilverStripe source code file LeftAndMain.EditForm.js:

Change tracking is enabled on all fields within the form. If you want to disable change tracking for a specific field, add a "no-change-track" class to it.

Journal

20130819

Tried setting window.onbeforeonload = null when button is clicked but nothing happens.