Ajax help => Scriptculous

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Aug 2007
Posts: 11
Reputation: bigtalk is an unknown quantity at this point 
Solved Threads: 0
bigtalk's Avatar
bigtalk bigtalk is offline Offline
Newbie Poster

Ajax help => Scriptculous

 
0
  #1
Jul 25th, 2008
Hello,

I'm a noob with PHP and unversed in Javascript, but I need to implement some Ajax in a page I'm building. I'm using the Scriptaculous libraries.

Here's the problem I'm having:
I have four different links in the menubar. When I click on the first link, it makes a div block appear using the effect "Appear". If I click the same link again, the div fades Effect.toggle . This works great. Now, I click on a new link and it does the same thing. Great. The problem arises if I have already clicked on link "A" and the div is showing and I then click on link "B". The div associated with link "B" appears over the div associated with link "A".

The help I'm asking:
When I click a link, it should first try to fade any visible div and then make its associated div appear.

This is what I've been trying (it doesn't quite work though):

my combo.js script:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. Effect.OpenUp = function(element) {
  2. element = $(element);
  3. new Effect.Appear(element, arguments[1] || {});
  4. }
  5.  
  6. Effect.CloseDown = function(element) {
  7. element = $(element);
  8. new Effect.Fade(element, arguments[1] || {});
  9. }
  10.  
  11. Effect.Combo = function(element) {
  12. element = $(element);
  13. if(element.style.display != 'none') {
  14. new Effect.CloseDown(element, arguments[1] || {});
  15. setTimeout('Effect.OpenUp(element, arguments[1] || {})', 250)
  16. }
  17. else { new Effect.OpenUp(element, arguments[1] || {}); }
  18. }

My menubar:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div id="menubar">
  2. <a href="#" onclick="Effect.Combo('box',{duration: .8});">about</a><br /><br /><br />
  3. <a href="#" onclick="Effect.Combo('box',{duration: .8});">tracks</a>
  4. </div>

My dispaying page:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div id="box" style="display:run-in;">
  2. <p>Content Stuff.</p>
  3. </div>


Thank you for any help!
nerding-out hard core.

Check out my music at:
www.JonRyser.com
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 11
Reputation: bigtalk is an unknown quantity at this point 
Solved Threads: 0
bigtalk's Avatar
bigtalk bigtalk is offline Offline
Newbie Poster

Re: Ajax help => Scriptculous

 
0
  #2
Jul 30th, 2008
SO, I guess it does work. I just needed to change:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. setTimeout('Effect.OpenUp(element, arguments[1] || {})', 250)
in my combo.js file to:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. setTimeout('Effect.OpenUp("box",{duration: 0.8});', 1000)
and it works. If anyone knows a cleaner way, please share. Again, I don't really know what I'm doing.

Thanks for any comments!
Last edited by bigtalk; Jul 30th, 2008 at 12:37 am. Reason: Fixed typo.
nerding-out hard core.

Check out my music at:
www.JonRyser.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC