Author: michiel
Date: 2010-06-28 00:00:00 +0200 (Mon, 28 Jun 2010)
New Revision: 42717
Modified:
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
Log:
Modified:
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
===================================================================
---
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
2010-06-25 17:09:49 UTC (rev 42716)
+++
mmbase/branches/MMBase-1_9/applications/searchrelate/src/main/webapp/mmbase/searchrelate/List.js.jsp
2010-06-27 22:00:00 UTC (rev 42717)
@@ -88,8 +88,8 @@
this.sortable = this.sortable == 'true';
this.autosubmit = this.autosubmit == 'true';
this.search = this.search == 'true';
+ this.committing = false;
-
// Whether every user input is currently valid (whith respect of both the
list's length and MMBaseValidator information).
this.valid = true;
// The reason(s) why it would not be valid.
@@ -222,9 +222,16 @@
// Before the page is left, we need to save. Arrange that here.
$(window).bind("beforeunload",
- function(ev) {
- List.prototype.leftPage = true;
- $(self.div).find(":input").attr("disabled", true);
+ function(ev) {
+ if (!List.prototype.leftPage) {
+ // avoid changes and leave during save;
+ $(document).find(":input").attr("disabled",
"disabled");
+ $(document).find("a").unbind().click(
+ function() {
+ return false; }
+ );
+ }
+ List.prototype.leftPage = true;
var result = self.commit(0, true);
if (result != null) {
ev.returnValue = confirm(result); //'<fmt:message
key="invalid" />';
@@ -726,14 +733,14 @@
List.prototype.commit = function(stale, leavePage) {
var result;
var self = this;
- if(this.needsCommit() && (! List.prototype.leftPage || leavePage)) {
+ if(this.needsCommit() && (! List.prototype.leftPage || leavePage) && (!
self.saving)) {
// if triggered unload prototype.leftPage is true, so normal commits
are cancelled. But the last 'leavePage' (which will happen asynchronously)
// does proceed. This is because we want this last commit to delay
actually leaving the page.
-
if (this.valid) {
var now = new Date();
if (stale == null) stale = this.defaultStale; //
if (now.getTime() - this.lastChange.getTime() > stale) {
+ self.saving = true;
var params = this.getListParameters();
params.leavePage = leavePage ? true : false;
@@ -758,7 +765,7 @@
this.loader();
$(self.div).trigger("mmsrStartSave", [self]);
result = null;
- self.saving = true;
+
// console.log("ASYNC " + (leavePage == null ? true :
!leavePage));
$.ajax({ type: "POST",
async: leavePage == null ? true : !leavePage,
@@ -797,11 +804,12 @@
}
} else {
result = null;
+ return result;
}
if (leavePage) {
// put a maximum on the duration time of the next while loop. Just to
be sure.
- $.timer(10000,
+ $.timer(5000,
function(timer) {
self.saving = false;
timer.stop();
@@ -809,6 +817,7 @@
);
while(self.saving) {
+ // console.log("Still saving");
// waiting a bit for that.
// There is no proper wait or join method in javascript.
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs