function AutosaveForm(formthis){
var alertTimerid = 0;
new Form.Observer('checkform', 0.3, function(){
clearTimeout (alertTimerid);
alertTimerid = setTimeout (function(){
formthis.request({
onComplete: function(){alert('Form data saved!')}
})
}, 1000)
})
}
I call AutosaveForm from html in the page. In Firefox it works fine,
after 1 second after the form is modified it submits the results and
alerts me that the data was saved. But in IE it just alerts me that
it was saved but doesn't actually save the data that was modified,
when I refresh the page its the old data. Any Ideas?
I don't know what's wrong, but I do have a couple of observations for
you -- they might help, you never know.
1. On this line:
new Form.Observer('checkform', 0.3, function(){
Since the function is otherwise reusable for multiple forms, I wonder
if you might want:
new Form.Observer(formthis.id, 0.3, function(){
...instead (or formthis.identify() if there's a chance that forms will
be passed in that don't have an ID). Otherwise, I could call
AutosaveForm($("myform")) and end up submitting changes to "myform"
when "checkform" changes, which probably isn't what you want.
2. You're relying on semicolon insertion. Semicolon insertion is a
very, very bad thing (especially when you start wanting to minify your
code for deployment), I would suggest _never_ relying on it. (But I
don't immediately see any reason to believe that's what's wrong.)
3. IE has this confusion around IDs and NAMEs, it puts them in the
same namespace although that's clearly completely wrong. I don't
suppose there might be something else on the page that has *either* a
name or id attribute with the value "checkform"? Because if there is,
it's anyone's guess which one will get picked at runtime, the behavior
is not reliable cross-browser. IDs (as I'm sure you know) must be
completely unique within the page, and with IE you also have to worry
about names getting conflated with them as well. Great fun.
FWIW (which may be nothing -- but I'd love to hear if one of those was
it),
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available
> function AutosaveForm(formthis){
> var alertTimerid = 0;
> new Form.Observer('checkform', 0.3, function(){
> clearTimeout (alertTimerid);
> alertTimerid = setTimeout (function(){
> formthis.request({
> onComplete: function(){alert('Form data saved!')}
> })
> }, 1000)
> })
> }
> I call AutosaveForm from html in the page. In Firefox it works fine,
> after 1 second after the form is modified it submits the results and
> alerts me that the data was saved. But in IE it just alerts me that
> it was saved but doesn't actually save the data that was modified,
> when I refresh the page its the old data. Any Ideas?
Ok so I modifed the function to suggestions on 1 and 2 just incase:
function AutosaveForm(formthis){
var alertTimerid = 0;
new Form.Observer(formthis, 0.3, function(){
clearTimeout (alertTimerid);
alertTimerid = setTimeout (function(){
formthis.request({
onComplete: function(){alert('Form data saved!');}
});
}, 1000);
});
}
3 was my first guess but I can't find any duplicates. I even went as
far are renaming the form to "aardvark" something thats def not
sharing that name/id with some other element and it still is a no go.
The form itself has name and ID specified as the same, I tried
removing the name, and then the ID to make sure it wasn't some funky
conflict there and still the same issue.
> Ok so I modifed the function to suggestions on 1 and 2 just incase:
> function AutosaveForm(formthis){ > var alertTimerid = 0; > new Form.Observer(formthis, 0.3, function(){ > clearTimeout (alertTimerid); > alertTimerid = setTimeout (function(){ > formthis.request({ > onComplete: function(){alert('Form data saved!');} > }); > }, 1000); > }); > }
> 3 was my first guess but I can't find any duplicates. I even went as > far are renaming the form to "aardvark" something thats def not > sharing that name/id with some other element and it still is a no go. > The form itself has name and ID specified as the same, I tried > removing the name, and then the ID to make sure it wasn't some funky > conflict there and still the same issue.
> Any other ideas?
on server side can you add a log? create a file when request is recived with request information. or using some debug (like firebug) for see what page is request. for debug the problem.
So at last change the request from "print.htm" to "data/print.htm". (Zope can handle with this without problem. how not find data in data, go up a level -dir1- and load data/print.htm)
> Ok so I modifed the function to suggestions on 1 and 2 just incase:
> function AutosaveForm(formthis){
> var alertTimerid = 0;
> new Form.Observer(formthis, 0.3, function(){
> clearTimeout (alertTimerid);
> alertTimerid = setTimeout (function(){
> formthis.request({
> onComplete: function(){alert('Form data saved!');}
> });
> }, 1000);
> });
> }
> 3 was my first guess but I can't find any duplicates. I even went as
> far are renaming the form to "aardvark" something thats def not
> sharing that name/id with some other element and it still is a no go.
> The form itself has name and ID specified as the same, I tried
> removing the name, and then the ID to make sure it wasn't some funky
> conflict there and still the same issue.