Forum: Rails Spinoffs (closed, excessive spam) Effect.SlideDown() not working properly.

351412b4c70a9fad154f30bcf8339666?d=identicon&s=25 Edwartine (Guest)
on 2008-06-12 09:30
(Received via mailing list)
If you go to http://www.worldsurfengine.com/Hawaii/home there is a
login function. Once logged in, it allows you to click "account" in
the same place that "login" is and it makes a div slide down from the
menu bar.

Basically, I have firebug installed and it doesn't detect any errors.
I have a cookie installed so that the drop down is persistent. The
problem is, when the account box starts off hidden, it won't drop
down, but it runs all the scripts correectly, because it sets the
cookie to the account box being open. If you refresh, then the box is
open, and if you click close, it closes. Without refreshing the page
if you click account, NOW the drop down will occur, but if you refresh
the page when the box is closed, and try to open it on the new page,
it once again won't open.

Any thoughts?

Here is an excerpt of the code i'm using:

The Javascript Functions Code:

<script type="text/javascript">
function toggleAccount() {
  obj = document.getElementById('accounttext');
  if (obj.innerHTML == "Account") {
    Effect.SlideDown('accountinfodiv');
    obj.innerHTML = "Close";
    $('menu').style.borderBottomColor = "transparent";
    $('menu').style.borderBottomWidth = "0px";
    new Ajax.Request('../includes/setCookie.php', {parameters:
'setcook=open'});
  }
  else {
    Effect.SlideUp('accountinfodiv')
    obj.innerHTML = "Account";
    setTimeout('$("menu").style.borderBottomWidth = "thin"; $
("menu").style.borderBottomColor = "#000000";', 1000);
    new Ajax.Request('../includes/setCookie.php', {parameters:
'setcook=closed'});
  }
}
</script>


HTML Menu Bar (You If you look under $authenticated) you'll find the
onclick-"toggleAccount()":

<{if not $authenticated }>
      <div style="float: right;"><a href="#" title="Login"
onclick="Modalbox.show('../public/loginfunctions.php', {title:
this.title, width: '650', height: '400', method: 'post', params:
'submit=Login%20Form&method=Login'}); return false;">Login</a> <img
style="vertical-align: middle;" src="/images/bluesurf/seperator.gif" /
> <a href="#" title="Login" onclick="Modalbox.show('../public/
loginfunctions.php', {title: this.title, width: '650', height: '400',
method: 'post', params: 'submit=Login%20Form&method=Register'});
return false;">Register</a></div>
    <{/if}>
<{if $authenticated }>
      <div style="float: right;"><a href="#" id="accounttext"
onclick="toggleAccount(); return false;">Account</a> <img
style="vertical-align: middle;" src="/images/bluesurf/seperator.gif" /
> <a href="#" title="Logout" onclick="Modalbox.show('/public/
loginfunctions.php', {title: this.title, width: 600, height: 400,
method: 'post', params: 'submit=Logout'}); return false;">Logout</a></
div>
    <{/if}><br />



Any thoughts?
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-12 15:28
(Received via mailing list)
Just a note on debugging: Ajax.Request() and setTimeout() both result in
code which is asynchronous (Greek for "impossible to debug" ;-)).  I
write a
blog post awhile back about how to patch both of these scenarios for the
purposes of testing, which you might find useful:

http://sustainablecode.com/blog/2008/01/testing-aj...

-Fred

On Thu, Jun 12, 2008 at 2:27 AM, Edwartine <brett.hinkle@gmail.com>
wrote:

>
> If you go to http://www.worldsurfengine.com/Hawaii/home there is a
> login function. Once logged in, it allows you to click "account" in
> the same place that "login" is and it makes a div slide down from the
> menu bar.
>
> Basically, I have firebug installed and it doesn't detect any errors.


--
Science answers questions; philosophy questions answers.
351412b4c70a9fad154f30bcf8339666?d=identicon&s=25 Edwartine (Guest)
on 2008-06-12 22:08
(Received via mailing list)
Thanks for the response,

the weird thing is that the AJAX is just to set the cookie for the
persistance as I was having no luck getting javascript to do it for
me. The script doesn't actually rely upon the AJAX and i've taken it
out and it doesn't change if it works or not.

The other thing is that the timer is just so that the bottom border of
the menu doesn't appear until the dropdown box is closed. Again this
is not part of something that is function for the dropdown script and
has also been removed during tests.

So from my view it doesn't seem like the setTimeout and AJAX requests
are messing it up, but then again i'm still learning Javascript....
much more comfortable in my home state of PHP. :)
This topic is locked and can not be replied to.