Hey guys, I''m new here and just checked out Prototype with Script.aculo.us and have to say it''s a great experience once you get the concept. However, I''m not very experienced with JS so I''m a bit stuck on something I think is quite easy to solve: What already works: A searchfield is observed by a DelayedObserver, a list of contacts is updated vie Ajax updater. What doesn''t work: I want to wrap the Ajax.Updater() function in a Fade() and an Appear() effect, so the old result fades out ... content update ... result fades in. Unfortunately that doesnt work: While the content fades out, it is already updated, because the Ajax.Updater works to fast! The new result basically flickers before it is completely faded. I tried the effect chains but found no way to add a regular function to it - I even made a workaround by creating a new effect "Updater", which is in fact not a new effect but a wrap for the Ajax.Updater() - but no luck, the problem is still there. Do I have to write an event chain mechanism myself? Best regards, Thomas --~--~---------~--~----~------------~-------~--~----~ 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 would personally perform my update using a standard ajax.request.
Please forgive any typos as I have typed this code direct into the message
window
new Ajax.Request("ajax.php?method=GetContacts&Filter=" +
$F(''SearchString''),
{ onSuccess: function (transport) {
var data = transport.responseText;
new Effect.Fade(''contactlist'', { afterFinish: function () {
$(''contactlist'').update(data);
new Effect.Appear(''contactlist'');
}
});
});
I think this might work, but as I said, I havent tested it.
Please change url, params, and ids as you see fit :)
Gareth
On 9/17/07, Thomas Murphy
<murphsite-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:>
>
> Hey guys,
>
> I''m new here and just checked out Prototype with Script.aculo.us
and
> have to say it''s a great experience once you get the concept.
However,
> I''m not very experienced with JS so I''m a bit stuck on
something I
> think is quite easy to solve:
>
> What already works:
> A searchfield is observed by a DelayedObserver, a list of contacts is
> updated vie Ajax updater.
>
> What doesn''t work:
> I want to wrap the Ajax.Updater() function in a Fade() and an Appear()
> effect, so the old result fades out ... content update ... result
> fades in. Unfortunately that doesnt work: While the content fades out,
> it is already updated, because the Ajax.Updater works to fast! The new
> result basically flickers before it is completely faded.
>
> I tried the effect chains but found no way to add a regular function
> to it - I even made a workaround by creating a new effect
"Updater",
> which is in fact not a new effect but a wrap for the Ajax.Updater() -
> but no luck, the problem is still there.
>
> Do I have to write an event chain mechanism myself?
>
> Best regards,
> Thomas
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Hi, On 17 Sep., 06:47, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would personally perform my update using a standard ajax.request. > > I think this might work, but as I said, I havent tested it. > Please change url, params, and ids as you see fit :)it works beautifully! Thank you. (Of course it only makes sense to fade out once I have received a successful answer, I wasn''t thinking about that...) One thing would make it perfect now: If I could check wether ''data'' is different from the current content of my target element. I tried a simple if(data != document.getElementById(''myDiv'').innerHTML) but it seems it always returns true. How can I compare the result to the current content? bye, Thomas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If data is HTML, then when it is updated into the element, theres a chance
the browser will rewrite it so this is a bad test to make.
I am not actually sure how you can compare one element to another, perhaps
you could use the new Element class and do something like:
var dataEl = new Element("div",data);
if (dataEl == $(''myDiv'')) alert(''same'');
but I have a feeling this wont work.
I''ll let someone else here suggest a better way to compare requested
HTML to
the current data in the element.
Gareth
On 9/17/07, Thomas Murphy
<murphsite-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:>
>
> Hi,
>
> On 17 Sep., 06:47, "Gareth Evans"
<agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > I would personally perform my update using a standard ajax.request.
> >
> > I think this might work, but as I said, I havent tested it.
> > Please change url, params, and ids as you see fit :)
>
> it works beautifully! Thank you.
> (Of course it only makes sense to fade out once I have received a
> successful answer, I wasn''t thinking about that...)
>
> One thing would make it perfect now: If I could check wether
''data'' is
> different from the current content of my target element.
> I tried a simple
> if(data != document.getElementById(''myDiv'').innerHTML)
> but it seems it always returns true.
> How can I compare the result to the current content?
>
> bye,
> Thomas
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Hi,
i found a solution, very easy:
I just save the result in a (in my case) class variable
this.currentResult and then I do something like this:
if(data != this.currentResult){
this.currentResult = data;
[...exchange content...]
}
bye,
Thomas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Ah that is a very good solution, it gets around the HTML rewriting. Cant beleive I didnt think of it. Gareth On 9/18/07, Thomas Murphy <murphsite-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > Hi, > > i found a solution, very easy: > I just save the result in a (in my case) class variable > this.currentResult and then I do something like this: > > if(data != this.currentResult){ > this.currentResult = data; > [...exchange content...] > } > > bye, > Thomas > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---