Is onFailure supposed to work with Ajax.Updater? I cannot get it to
work:
new Ajax.Updater(elementID, url, {
method: ''get'',
evalScripts: true,
onFailure: function() {
element.update(''<strong>Error Loading
Content</strong>'');
}
});
If I use Ajax.Request it works flawlessly but if I use that I loose
the necessary evalScripts option.
Am I missing something here?
Thanks,
Mike
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
I don''t think that expression will work because the element variable
is undefined in that scope. Element is the class and all the fun
methods that you can use. but you must send the update function an
element to update, or alternatively use it as a member function of an
extended element.
I believe if you said Element.update("myFailureNotify",
"''<strong>Error Loading
Content</strong>''"); and you have
<div id="myFailureNotify"></div> somewhere in your HTML
then you may
get your desired effect. On a CSS note you would be better off
removing the <strong> markup and adding font-weight:bold; to the
ruleset of the #myFailureNotify selector.
Cheers,
Matt
On Jul 16, 4:11 pm, MMason
<mpaqdigi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Is onFailure supposed to work with Ajax.Updater? I cannot get it to
> work:
>
> new Ajax.Updater(elementID, url, {
> method: ''get'',
> evalScripts: true,
> onFailure: function() {
> element.update(''<strong>Error Loading
Content</strong>'');
> }
>
> });
>
> If I use Ajax.Request it works flawlessly but if I use that I loose
> the necessary evalScripts option.
>
> Am I missing something here?
>
> Thanks,
> Mike
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
I copied just a small block out of a larger function. Here is the
entire function where ''element'' is defined:
updatePod = function(url,headerText,elementID,headerID){
var element = $(elementID);
var header = $(headerID);
// Random identifier for created div layers.
var randID = ''elem'' + Math.random();
// onCreate
element.hide();
// Insert loading graphic
new Insertion.After(elementID,''<div id="'' + randID +
''"
style="padding:5px;"><img
src="../assets/images/icons/loading.gif"
width="18" height="18" align="absmiddle">
Loading...</div>'');
// Change the header
header.update(headerText);
//Update the region
new Ajax.Updater(elementID, url, {
method: ''get'',
evalScripts: true,
onSuccess: function(transport) {
showElement(elementID);
hideElement(randID);
},
onFailure: function() {
element.update(''<strong>Error Loading
Content</strong>'');
}
});
}
Should this work?
Thanks for the quick reply,
MIke
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Hey MMason,
You''re correct, element is defined in that scope, i retract
my previous prescription.
I''d recommend using Ajax.Request to see if you''re
method is
working. What I believe could potentially be causing the problem is
the Updater''s native code is attempting to update the element after
your onFailure function has already updated it, in which case you
might see some odd behavior, but i am not sure of that.
I also highly highly recommend downloading firebug for help
with debugging ajax applications, it allows you to monitor all XHR
requests, you can read the XHR''s post request variables and its
response, whether it fails or not.
Cheers,
Matt
On Jul 16, 11:29 pm, MMason
<mpaqdigi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I copied just a small block out of a larger function. Here is the
> entire function where ''element'' is defined:
>
> updatePod = function(url,headerText,elementID,headerID){
> var element = $(elementID);
> var header = $(headerID);
> // Random identifier for created div layers.
> var randID = ''elem'' + Math.random();
> // onCreate
> element.hide();
> // Insert loading graphic
> new Insertion.After(elementID,''<div id="''
+ randID + ''"
> style="padding:5px;"><img
src="../assets/images/icons/loading.gif"
> width="18" height="18" align="absmiddle">
Loading...</div>'');
> // Change the header
> header.update(headerText);
>
> //Update the region
> new Ajax.Updater(elementID, url, {
> method: ''get'',
> evalScripts: true,
> onSuccess: function(transport) {
> showElement(elementID);
> hideElement(randID);
> },
> onFailure: function() {
> element.update(''<strong>Error Loading
Content</strong>'');
> }
> });
>
> }
>
> Should this work?
>
> Thanks for the quick reply,
> MIke
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Matt,
Thanks for the reply. Firebug... I wouldn''t have made through my first
week of learning Prototype without Firebug. Invaluable tool. Web
Developer plugin is also extremely handy.
I have another function that uses Ajax.Request and it works as
expected. I actually prefer the Ajax.Request call to Ajax.Updater. It
seems to have more control except that it stripped out my JavaScript
code rendering it worthless.
All that said, I believe I have it working. I think it boiled down to
a variable name conflict, still not quite sure. I had the variable
named ''element'' which seemed to conflict with the Prototype
element
object.
I changed this:
element.update(''<strong>Error Loading
Content</strong>'');
To:
$(elementID).update(''<strong>Error Loading
Content</strong>'');
Thanks again for the help.
Mike
On Jul 18, 4:05 pm, Matt
<mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hey MMason,
>
> You''re correct, element is defined in that scope, i
retract
> my previous prescription.
>
> I''d recommend using Ajax.Request to see if
you''re method is
> working. What I believe could potentially be causing the problem is
> the Updater''s native code is attempting to update the element
after
> your onFailure function has already updated it, in which case you
> might see some odd behavior, but i am not sure of that.
>
> I also highly highly recommend downloading firebug for help
> with debugging ajax applications, it allows you to monitor all XHR
> requests, you can read the XHR''s post request variables and its
> response, whether it fails or not.
>
> Cheers,
> Matt
>
> On Jul 16, 11:29 pm, MMason
<mpaqdigi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > I copied just a small block out of a larger function. Here is the
> > entire function where ''element'' is defined:
>
> > updatePod = function(url,headerText,elementID,headerID){
> > var element = $(elementID);
> > var header = $(headerID);
> > // Random identifier for created div layers.
> > var randID = ''elem'' + Math.random();
> > // onCreate
> > element.hide();
> > // Insert loading graphic
> > new Insertion.After(elementID,''<div
id="'' + randID + ''"
> > style="padding:5px;"><img
src="../assets/images/icons/loading.gif"
> > width="18" height="18"
align="absmiddle"> Loading...</div>'');
> > // Change the header
> > header.update(headerText);
>
> > //Update the region
> > new Ajax.Updater(elementID, url, {
> > method: ''get'',
> > evalScripts: true,
> > onSuccess: function(transport) {
> > showElement(elementID);
> > hideElement(randID);
> > },
> > onFailure: function() {
> > element.update(''<strong>Error Loading
Content</strong>'');
> > }
> > });
>
> > }
>
> > Should this work?
>
> > Thanks for the quick reply,
> > MIke
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---