gorans
2007-Jul-30 14:27 UTC
Event.observe wont execute in IE 7 but fine in FF, Safari! Why?
Hi,
I''m submitting a form with Ajax, but I load the form dynamically first
using Ajax.Update() to a div (#newsletter). I wait till the DOM
including the new form has loaded before I attach Event.Observer to
the form (''theform'') but in IE the actual code
doesn''t execute.
Snippet below:
----------------------
var form_loaded = false;
var page_loaded = false;
// Load the initial form as HTML into the newsletter DIV
// When totally complete, call attachEvent()
new Ajax.Updater(''newsletter'',
''/newsletter/'', {
method: ''get'',
parameters: {
differentiator: Math.floor(Math.random()*50000) // Fix
for IE''s retardation
},
onComplete: function() {
form_loaded = true;
attachEvent();
}
});
// Wait till the page has loaded
// This covers instances where the page DOM loads after the form
Event.observe(window, ''load'', function() {
page_loaded = true;
attachEvent();
});
function attachEvent() {
/* Attach a handler to the submit observe event
* Checks to ensure the Dom has loaded as well as the actual form.
*/
if (form_loaded && page_loaded) {
alert("THIS ALWAYS GETS EXECUTED!!");
Event.observe(''theform'', ''submit'',
submitForm); // ** The Issue **
alert("IE JUST DOESN''T GET TO HERE");
}
}
// Called to do process
function submitForm(e) {
var aj_form = Event.findElement(e, ''form''); // The
ajax form
we are using
....
}
I''ve scaled google for answers, but all I have come to understand is
that there is something to do with IE and the window''s events. Then I
tried using .bindAsEventListener() which didn''t change anything.
It''s driving me insane !!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
gorans
2007-Aug-01 01:24 UTC
Re: Event.observe wont execute in IE 7 but fine in FF, Safari! Why?
hello? On Jul 31, 12:27 am, gorans <gor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m submitting a form with Ajax, but I load the form dynamically first > using Ajax.Update() to a div (#newsletter). I wait till the DOM > including the new form has loaded before I attach Event.Observer to > the form (''theform'') but in IE the actual code doesn''t execute. > > Snippet below: > ---------------------- > var form_loaded = false; > var page_loaded = false; > > // Load the initial form as HTML into the newsletter DIV > // When totally complete, call attachEvent() > > new Ajax.Updater(''newsletter'', ''/newsletter/'', { > method: ''get'', > parameters: { > differentiator: Math.floor(Math.random()*50000) // Fix > for IE''s retardation > }, > onComplete: function() { > form_loaded = true; > attachEvent(); > } > > }); > > // Wait till the page has loaded > // This covers instances where the page DOM loads after the form > Event.observe(window, ''load'', function() { > page_loaded = true; > attachEvent(); > > }); > > function attachEvent() { > /* Attach a handler to the submit observe event > * Checks to ensure the Dom has loaded as well as the actual form. > */ > if (form_loaded && page_loaded) { > alert("THIS ALWAYS GETS EXECUTED!!"); > Event.observe(''theform'', ''submit'', > submitForm); // ** The Issue ** > alert("IE JUST DOESN''T GET TO HERE"); > } > > } > > // Called to do process > function submitForm(e) { > var aj_form = Event.findElement(e, ''form''); // The ajax form > we are using > .... > > } > > I''ve scaled google for answers, but all I have come to understand is > that there is something to do with IE and the window''s events. Then I > tried using .bindAsEventListener() which didn''t change anything. > > It''s driving me insane !!!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---