943,870 Members | Top Members by Rank

Ad:
Jul 25th, 2008
0

Ajax help => Scriptculous

Expand Post »
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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bigtalk is offline Offline
16 posts
since Aug 2007
Jul 30th, 2008
0

Re: Ajax help => Scriptculous

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bigtalk is offline Offline
16 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: java script help want to use it differently
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Help with adding java to a website





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC