Ok I have the following code if (Element.visible(objResultsDiv)) { Effect.BlindUp(objResultsDiv, { queue: ''front'', afterFinish: function(e) { objResultsDiv.innerHTML = ''''; objResultsDiv.appendChild(objErrorList); objResultsDiv.appendChild(Builder.node(''br'')); } }); } else { objResultsDiv.innerHTML = ''''; objResultsDiv.appendChild(objErrorList); objResultsDiv.appendChild(Builder.node(''br'')); } Effect.BlindDown(objResultsDiv, {queue:''end''}); Now as you can see its a bit redundent (The else blog incase you missed that). Is there any way to fix this issue having a toggle when some code is run half way threw the toggle? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :> Ok I have the following code > > if (Element.visible(objResultsDiv)) { > Effect.BlindUp(objResultsDiv, { > queue: ''front'', > afterFinish: function(e) { > objResultsDiv.innerHTML = ''''; > objResultsDiv.appendChild(objErrorList); > objResultsDiv.appendChild(Builder.node(''br'')); > } > }); > } > else { > objResultsDiv.innerHTML = ''''; > objResultsDiv.appendChild(objErrorList); > objResultsDiv.appendChild(Builder.node(''br'')); > } > Effect.BlindDown(objResultsDiv, {queue:''end''}); > > Now as you can see its a bit redundent (The else blog incase you missed > that). Is there any way to fix this issue having a toggle when some > code is run half way threw the toggle?OK, here are a few questions/suggestions about this: a) why do you bother changing the element''s contents in the blindup''s afterFinish, since the element is NOT visible at this point, and you WILL update its contents before blinddown anyhow? b) incidentally, why the heck do you add a <br/> node after your list? What is your objErrorList like? Isn''t it some ul/ol? Then why do you need a br? Some float-related issue here? c) Assuming I correctly see afterFinish as useless in (a), you could just go like this: if (!Element.visible(objResultsDiv)) { // your 2-3 lines of contents update. BTW, maybe use .update('''') // instead of .innerHTML = ''''; } Effect.toggle(objResultsDiv, ''blind''); ''HTH -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-25 16:00 UTC
Re: Small Delema
a) I want to update the content when its not visiable because it looks better than rolling it down then updating the cotent. The content is changing when its not visialbe. b) br is added to create a little extra space between the errors retruned and the form content. c) .update is indeed a better solution. Thanks I still however would like to eliminate the code redundency, would it be possilbe to make the blindup pause javascript execution until it is finished? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The solution I suggested also gets rid of the duplication, if you look at it closely. There''s no *need* to updated after BlindUp, since you''re going to update before BlindDown anyway. This is if you call this code to toggle the status. Your original code seemed to allow for call after the contents had been rolled down already. If you need this (first invoke = update + blinddown, later invokes = up + update + down), tell me so, and I''ll post a code for this. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-25 17:52 UTC
Re: Small Delema
Ok let me clerify this. The block thats being toggled is defaulting to not visible, however after some ajax is run it can be toggled on. Now if it was toggled on and there is another error i needs to be "re-toggled on". That means it needs to be rolled up, then after thats finished it needs to be updated and then rolled down. the problem is that if it is currently visible and we roll it up, and then update, the update happens while the roll up is currently being executed. Here is a simple example... <div id="test" style="display: none;"></div> <script type="text/javascript"> objEditDiv = document.getElementById(''test''); new Ajax.Request(window.location, { method: ''post'', postBody: ''.....'', onSuccess: function(e) { if (Element.visible(objEditDiv)) { Effect.Fade(objEditDiv, {queue: ''front''}); } objEditDiv.update(, ''Random #: '' + (Math.round((Math.random()*9)+1))); Effect.Appear(objEditDiv, {queue: ''end''}); } } </script> Now what i need to happen is i need the fade out to happen, then update the random number after fade out has finished, then fade the random number back in. What acctually ends up happening is the fade starts, about 1/4 the way threw the random number updates, and the just reappres with out fadeing. Now if i remove the if check, wired things start happening, like it hangs, wont fade back in, etc. The example you provided does not solve the issue that the starting state of div id="test" is unknow at code execution. It could be visible, it could be hidden and we need to make sure its hidden before updateing. Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-25 19:33 UTC
Re: Small Delema
Doing something retarded like the following seems to work, but its kind of retarded. if (Element.visible(objEditDiv)) { new Effect.Fade(objEditDiv, {queue: ''front''}); } new Effect.Opacity(objEditDiv, { duration: 0, from:1.0, to:1.0, queue: ''end'', afterFinish: function(e){ objEditDiv.update(, ''Random #: '' + (Math.round((Math.random()*9)+1))); } }); new Effect.Appear(objEditDiv, {queue: ''end''}); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey, OK, so what you need to get for this is: - effects run in parallel by default. - you should invoke them using "new" to make them work properly. - putting them in a queue is good, but not good enough: the queueing mechanism is used to adjust their scheduled start time, it won''t handle the additional Ajax.Updater-induced delay (request/response time) particularly well. However, using a 2-limited dedicated queue can help with preventing issues when another update is request while an update is going on still. So all you''re left with is a rather spewy piece of code, although we can factor the update code with a function on the side. Try this on for size (untested, based on SVN): function updateContents(obj, errorListDOM) { obj.clear(); obj.appendChild(errorListDOM); // And let''s forego the BR and use proper CSS instead, shall we? new Effect.BlindDown(obj, { queue: { scope: ''results'', limit: 2 }}); } function updateResults(resultsContainer, errorListDOM) { resultsContainer = $(resultsContainer); if (resultsContainer.visible()) { new Effect.BlindUp(resultsContainer, { queue: { scope: ''results'', limit: 2 }, afterFinish: function() { updateContents(resultsContainer, errorListDOM); } }); } else { updateContents(resultsContainer, errorListDOM); } } // updateResults In the end, it''s pretty much your original code, although with a dedicated queue, the assurance that the BlindDown occurs after the update no matter what, and a factored update/blindDown code. There''s not much for it, I''m afraid! -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heispsychotic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-25 23:32 UTC
Re: Small Delema
Excelent I think it got it working! Thank you agaom for all your help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---