Browse Source

Prevent page reload only for form builder

Vova Tkach 6 years ago
parent
commit
00a41aaccd
4 changed files with 7 additions and 5 deletions
  1. 5 3
      assets/cp.scripts.js
  2. 0 0
      assets/cp.scripts.js.go
  3. 1 1
      consts/consts.go
  4. 1 1
      engine/builder/data_form.go

+ 5 - 3
assets/cp.scripts.js

@@ -125,9 +125,11 @@ $(document).ready(function() {
 		}
 		}
 
 
 		// Mark body if any data in form was changed
 		// Mark body if any data in form was changed
-		$(this).find('input, textarea, select').on('input', function() {
-			$('body').addClass('data-changed');
-		});
+		if($(this).hasClass('prev-data-lost')) {
+			$(this).find('input, textarea, select').on('input', function() {
+				$('body').addClass('data-changed');
+			});
+		}
 	});
 	});
 
 
 	// Remove alert from modal on close
 	// Remove alert from modal on close

File diff suppressed because it is too large
+ 0 - 0
assets/cp.scripts.js.go


+ 1 - 1
consts/consts.go

@@ -6,7 +6,7 @@ import (
 
 
 const Debug = true
 const Debug = true
 const ServerVersion = "1.0.0"
 const ServerVersion = "1.0.0"
-const AssetsVersion = "6"
+const AssetsVersion = "7"
 const AssetsPath = "assets"
 const AssetsPath = "assets"
 const DirIndexFile = "index.html"
 const DirIndexFile = "index.html"
 
 

+ 1 - 1
engine/builder/data_form.go

@@ -30,7 +30,7 @@ type DataFormField struct {
 }
 }
 
 
 func DataForm(wrap *wrapper.Wrapper, data []DataFormField) string {
 func DataForm(wrap *wrapper.Wrapper, data []DataFormField) string {
-	result := `<form class="data-form" action="/cp/" method="post" autocomplete="off">`
+	result := `<form class="data-form prev-data-lost" action="/cp/" method="post" autocomplete="off">`
 	result += `<div class="hidden">`
 	result += `<div class="hidden">`
 	for _, field := range data {
 	for _, field := range data {
 		if field.Kind == DFKHidden {
 		if field.Kind == DFKHidden {

Some files were not shown because too many files changed in this diff