Move setting currentValues after we initialize the toggleables. It's needed because otherwise the DOM is slighltly different, for example the select has a default value, while after initializing the toggleables, if the select is not enabled, the default value is null. Fixes the annoying "unsaved changes" promp appearing even when no changes were made to the page.

This commit is contained in:
Flavio Copes
2015-08-03 14:46:12 +02:00
parent b870fffcbe
commit c2bd95eed7
2 changed files with 7 additions and 2 deletions

View File

@@ -113,6 +113,9 @@
scanToggleable(this);
scan(this);
this.scanned = true;
//We can now initialize window.currentValues as toggleables are initialized
window.currentValues = getState();
};
Form.factories = {};

View File

@@ -12,8 +12,10 @@ var getState = function(){
$(function(){
var currentValues = getState(),
clickedLink;
//defined to make clear it's global, but initialized in ./forms/form.js: we must wait to scan the
//toggleables elements, otherwise the DOM changes and `beforeunload` detects unsaved changes
var currentValues;
var clickedLink;
// selectize
$('input.page-filter').selectize({